Flash 8 Tips: Import
The import
statement helps you to import a class into Flash so that you do not need to type the full path to reference to a class.
Taking the new Matrix
class as an example:
import flash.geom.Matrix;
mat = new Matrix();
can be written as:
mat = new flash.geom.Matrix();
Note:
1> the import
statement only import classes into the current frame or object. Therefore, for another frame or object, you will need to import again or type the full path to access the class.
2> if an imported class is not used, it will not be exported in the swf, which means the file size will not be affected.
3> the import
statement is only needed when you want to make a new instance (using the constructor e.g. new Matrix()
) of that class. In the following example, we do not need to import anything as the matrix object is copied from an existing matrix:
mat = mc.transform.matrix;
mat.translate(10,0);
mc.transform.matrix = mat;
We can access all the matrix methods and properties of mat
without importing anything.
aaa
Comment by Anonymous — August 15, 2006 @ 1:33 pm