ActionScript 3 Object Oriented Programming Packages


Packages are bundles of classes. Every class must be declared within a package using the package statement. The package statement is followed by the name of your package, or followed by nothing in the case of adding classes to the top-level package. Sub-packages are created using dot (.) delimitation. The package statement is followed by a block which will contain a single class definition. Examples:

package {
    // The top level package.

package world {
    // A package named world.

package world.monsters {
    // A package named monsters within a package named world.

Packages should correlate to the file structure of the classes relative to the source root. Assuming you have a source root folder named src, the above could be correctly represented in the filesystem as: