Macromedia flex 2-migrating applications to flex 2 Manual De Usuario

Descargar
Página de 184
26
ActionScript 2.0 to 3.0
Using packages
The 
package
 statement syntax has changed. In addition, you are now required to put custom 
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
 statements before imports, wrapped around the entire class. For 
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 { ... }
}