ActionScript Packages
Packages in ActionScript 3
Code in ActionScript is structured the same way Java code is structured. Each ActionScript file must declare its package and wrap any externally visible class in the package. A top level package does not need a name. So for a Foo
class at the top level, it would look like this:
package {
class Foo {
public function Foo() {
}
}
}
You can name your folder structure any way you like, but an accepted convention is to nest it in a unique domain to prevent potential package conflicts. So for a class MyFoo
you might have a folder structure like this: src/com/acme/MyFoo.as
and the class would look like this:
package com.acme {
class MyFoo {
public function MyFoo() {
}
}
}
Always structure your packages, so all classes have a unique qualified path.