Using packages
The
statement syntax has changed. In addition, you are now required to put custom
package
ActionScript components inside packages.
If you do not put a class inside a package, then the class is only visible in the current script.
For example:
class Foo {}
is a class that is not in any package, so it is only visible in the current script. If you put a class
in an unnamed package:
package { public class Foo {} }
Then you can access the class from any script. All scripts import the unnamed package by
default.
Package statement syntax
You now use a package statement rather than dot notation syntax to declare classes inside
packages. You add
package
example, to place the Button class in the mx.controls package in Flex 1.5:
class mx.controls.Button extends mx.core.UIComponent {
function Button() {
}
}
This implicitly declared that class Button was in package mx.controls. To place the Button
class in the mx.controls package in Flex 2:
package mx.controls {
public class Button extends mx.core.UIComponent {
public function Button() {
}
}
}
Custom component packages
ActionScript 3.0 now requires that all ActionScript components be inside packages. These
packages can be unnamed; for example:
package {
class MyClass { ... }
}
26
ActionScript 2.0 to 3.0
statements before imports, wrapped around the entire class. For
Need help?
Do you have a question about the FLEX 2-MIGRATING APPLICATIONS TO FLEX 2 and is the answer not in the manual?
Questions and answers