This is a blog about Flash & AS by betaruce :-)



Calendar

June 2007
M T W T F S S
« May    
  1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30  

September 18, 2005

Flash 8 Tips: Import

Filed under: Using Flash — betaruce @ 12:32 pm

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.

• • •

1 Comment »

  1. aaa

    Comment by Anonymous — August 15, 2006 @ 1:33 pm

Comments RSS • TrackBack URI

Leave a comment

Powered by: WordPress • Template by: Priss