Subclasses of dynamic classes are also dynamic, with one exception. Subclasses of the built-in
MovieClip class are not dynamic by default, even though the MovieClip class itself is dynamic.
This implementation provides you with more control over subclasses of the MovieClip class,
because you can choose to make your subclasses dynamic or not:
class A extends MovieClip {}
dynamic class B extends A {}
class C extends B {}
class D extends A {}
dynamic class E extends MovieClip{} // E is dynamic
The following built-in classes are dynamic: Array, ContextMenu, ContextMenuItem, Function,
LoadVars, LocalConnection, MovieClip, SharedObject and TextField.
Using packages
When you are creating classes, organize your ActionScript class files in packages. A package is a
directory that contains one or more class files and that resides in a designated classpath directory
(see the previous section,
packages, called subpackages, each with its own class files.
Package names must be identifiers; that is, the first character must be a letter, underscore (
dollar sign (
), and each subsequent character must be a letter, number, underscore, or dollar sign.
$
Packages are commonly used to organize related classes. For example, you might have three
related classes, Square, Circle, and Triangle, that are defined in Square.as, Circle.as, and
Triangle.as. Assume that you've saved the AS files to a directory specified in the classpath, as
shown in the following example:
// In Square.as:
class Square {}
// In Circle.as:
class Circle {}
// In Triangle.as:
class Triangle {}
Because these three class files are related, you might decide to put them in a package (directory)
called Shapes. In this case, the fully qualified class name would contain the package path, as well
as the simple class name. Package paths are denoted with dot (.) syntax, where each dot indicates
a subdirectory.
For example, if you placed each AS file that defines a shape in the Shapes directory, you would
need to change the name of each class file to reflect the new location, as follows:
// In Shapes/Square.as:
class Shapes.Square {}
// In Shapes/Circle.as:
class Shapes.Circle {}
// In Shapes/Triangle.as:
class Shapes.Triangle {}
// A is not dynamic
// B is dynamic
// C is dynamic
// D is not dynamic
"Understanding the
classpath"). A package can, in turn, contain other
), or
_
Using packages
57
Need help?
Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?