New Import Directive
The import directive in ActionScript 3 is a little different than import in ActionScript 2. In AS2, import was used solely as a name shortener for classes defined in packages; it was not required to use a class. Instead of using import, you could just have used the class's full name. ex:
ActionScript Code:
// ActionScript 2
var myPoint:flash.geom.Point = new flash.geom.Point(0,0);
In ActionScript 3, the import directive is required to access classes in their packages, even if you reference the class using its full name. You can still use the full name (or just the imported class name), but the import is required
ActionScript Code:
// ActionScript 3
import flash.geom.Point;
var myPoint:flash.geom.Point = new flash.geom.Point(0,0);
As with AS2, you can also use the wildcard character (*) in AS3 to import all classes within a package.
ActionScript Code:
import flash.geom.*;

0 评论:
发表评论