Classes and packages

You can organize your classes in packages. A package is a folder that resides within a top-level classpath folder. Any AS class file that resides directly in a top-level classpath folder (for example, C:\Documents and Settings\userName\Application Data\Macromedia\Flash MX2\en\Configuration\Classes\) belongs to the default package.

To create a new package, create a folder within a top-level classpath folder. The name of the folder is the name of the package. You can nest folders within this package to create subpackages. For example, if you have a Car class, you could create a package called Vehicles to contain the Car class file. If you later create a Truck class or Bus class, you could include those files in the same Vehicles package.

The class name you specify in the class statement must match the full path of the package that contains the class file. Use dot syntax to indicate packages, subpackages, and class names. For example, once you put the Car class file in the Vehicles package, you would need to change the class name to match the path of the Car.as file:

// In file Vehicles/Car.as:

class Vehicles.Car {
	// Car class properties, methods.
}