Example
The following example creates three matrixes that define transformations for three rectangle
movie clips. The first two matrixes
the two rectangles
rectangleMc_1
using the
method on
concat()
scaleAndRotateMatrix
it.
import flash.geom.Matrix;
import flash.geom.Transform;
var rectangleMc_0:MovieClip = createRectangle(20, 80, 0x000000);
var rectangleMc_1:MovieClip = createRectangle(20, 80, 0xFF0000);
var rectangleMc_2:MovieClip = createRectangle(20, 80, 0x00FF00);
var rectangleMc_3:MovieClip = createRectangle(20, 80, 0x0000FF);
var rectangleTrans_1:Transform = new Transform(rectangleMc_1);
var rectangleTrans_2:Transform = new Transform(rectangleMc_2);
var rectangleTrans_3:Transform = new Transform(rectangleMc_3);
var rotate45Matrix:Matrix = new Matrix();
rotate45Matrix.rotate(Math.PI/4);
rectangleTrans_1.matrix = rotate45Matrix;
rectangleMc_1._x = 100;
trace(rotate45Matrix.toString()); // (a=0.707106781186548,
b=0.707106781186547, c=-0.707106781186547, d=0.707106781186548, tx=0,
ty=0)
var doubleScaleMatrix:Matrix = new Matrix();
doubleScaleMatrix.scale(2, 2);
rectangleTrans_2.matrix = doubleScaleMatrix;
rectangleMc_2._x = 200;
trace(doubleScaleMatrix.toString()); // (a=2, b=0, c=0, d=2, tx=0, ty=0)
var scaleAndRotateMatrix:Matrix = doubleScaleMatrix.clone();
scaleAndRotateMatrix.concat(rotate45Matrix);
rectangleTrans_3.matrix = scaleAndRotateMatrix;
rectangleMc_3._x = 300;
trace(scaleAndRotateMatrix.toString()); // (a=1.4142135623731,
b=1.41421356237309, c=-1.41421356237309, d=1.4142135623731, tx=0, ty=0)
rotate45Matrix
and
rectangleMc_2
rotate45Matrix
. This matrix is then applied to
and
doubleScaleMatrix
. Then the third matrix is created
and
doubleScaleMatrix
rectangleMc_3
Matrix (flash.geom.Matrix)
are applied to
to create
to scale and rotate
769
Need help?
Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?