03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

myMatrix.translate(100,200);<br />

trace(myMatrix.toString()); // (a=1.6, b=1.2, c=-1.2, d=1.6, tx=100,<br />

ty=200)<br />

myMatrix.scale(2, 2);<br />

trace(myMatrix.toString()); // (a=3.2, b=2.4, c=-2.4, d=3.2, tx=200,<br />

ty=400)<br />

myMatrix.identity();<br />

trace(myMatrix.toString()); // (a=1, b=0, c=0, d=1, tx=0, ty=0)<br />

invert (Matrix.invert method)<br />

public invert() : Void<br />

Performs the opposite transformation of the original matrix. You can apply an inverted matrix<br />

to an object to undo the transformation performed when applying the original matrix.<br />

Availability: <strong>ActionScript</strong> 1.0; Flash Player 8<br />

Example<br />

The following example creates halfScaleMatrix by calling the invert() method of<br />

doubleScaleMatrix, <strong>and</strong> then demonstrates that the two are Matrix inverses of one another,<br />

that is, matrixes that undo any transformations performed by the other. The example shows<br />

this inversion by creating originalAndInverseMatrix, which is equal to noScaleMatrix.<br />

import flash.geom.Matrix;<br />

import flash.geom.Transform;<br />

var rectangleMc_0:MovieClip = createRectangle(20, 80, 0xFF0000);<br />

var rectangleMc_1:MovieClip = createRectangle(20, 80, 0x00FF00);<br />

var rectangleMc_2:MovieClip = createRectangle(20, 80, 0x0000FF);<br />

var rectangleMc_3:MovieClip = createRectangle(20, 80, 0x000000);<br />

var rectangleTrans_0:Transform = new Transform(rectangleMc_0);<br />

var rectangleTrans_1:Transform = new Transform(rectangleMc_1);<br />

var rectangleTrans_2:Transform = new Transform(rectangleMc_2);<br />

var rectangleTrans_3:Transform = new Transform(rectangleMc_3);<br />

var doubleScaleMatrix:Matrix = new Matrix(2, 0, 0, 2, 0, 0);<br />

rectangleTrans_0.matrix = doubleScaleMatrix;<br />

trace(doubleScaleMatrix.toString()); // (a=2, b=0, c=0, d=2, tx=0, ty=0)<br />

var noScaleMatrix:Matrix = new Matrix(1, 0, 0, 1, 0, 0);<br />

rectangleTrans_1.matrix = noScaleMatrix;<br />

rectangleMc_1._x = 100;<br />

trace(noScaleMatrix.toString()); // (a=1, b=0, c=0, d=1, tx=0, ty=0)<br />

Matrix (flash.geom.Matrix) 785

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!