ActionScript 3.0
class definitions use syntax that is similar to that used in
ActionScript 2.0 class definitions. Proper syntax for a class definition
calls for the class keyword followed by the class name. The class body,
which is enclosed by curly braces ({}), follows the class name.
For example, the following code creates a class named Shape that contains one variable, named visible:
public class Shape
{
var visible:Boolean = true;
}
One
significant syntax change involves class definitions that are inside a
package. In ActionScript 2.0, if a class is inside a package, the
package name must be included in the class declaration. In ActionScript
3.0, which introduces the package statement, the package name must be
included in the package declaration instead of in the class declaration.
For example, the following class declarations show how the BitmapData
class, which is part of the flash.display package, is defined in
ActionScript 2.0 and ActionScript 3.0:
// ActionScript 2.0
class flash.display.BitmapData {}
// ActionScript 3.0
package flash.display
{
public class BitmapData {}
}