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


September 2005
« Aug   Oct »
  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();


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;
mc.transform.matrix = mat;

We can access all the matrix methods and properties of mat without importing anything.

• • •

Flash 8 Tips: Matrix

Filed under: Using Flash — betaruce @ 2:45 am

We can use Matrix to do scaling and rotation on MovieClips. However, if we use the method scale() and rotate() of the Matrix class, the translation of the mc will also be affected, i.e. the tx and ty values are also changed.

Therefore, I may not use scale() if I want to scale a mc with matrix. Instead I will do the following (assume that there’s a movieclip named “mc” on the stage):

mat = mc.transform.matrix;
mat.a += .1;
mat.d += .1;
mc.transform.matrix = mat;

Scaling is done simply by changing the values of a and d.

For rotation, however, since I do not want to do so many sin and cos calculations, I still apply the rotate() method, and afterwards change the tx and ty back to their original values.

mat = mc.transform.matrix;
mat2 = mat.clone();
mat.tx = mat2.tx;
mat.ty = mat2.ty;
mc.transform.matrix = mat;

By using either of these 2 methods, we can do scaling and rotation with the mc remain in the same place (but not moving away).

• • •

Powered by: WordPress • Template by: Priss

cheap phentermine phentermine site phentermine effects online phentermine phentermine prescription buy phentermine online phentermine alternatives phentermine deit pill cheap generic phentermine order phentermine online Clenbuterol Phentermine online pharmacy phentermine buy phentermine weight loss pill Cialis Comparison Viagra Cheap Viagra Online Prescription generic viagra sale viagra online viagra viagra pill discount sale viagra Generico Impotencia Viagra viagra sildenafil citrate Xanax Online xanax order xanax valium versus xanax levitra order levitra levitra Online buy levitra cialis viagra levitra