13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Working with geometry<br />

The resulting skew is th<strong>en</strong> applied to the existing matrix by concat<strong>en</strong>ating the two matrixes, as the following example<br />

shows:<br />

sourceMatrix.concat(skewMatrix);<br />

return sourceMatrix;<br />

The scale() method<br />

The following example shows the scale() method adjusts the scale factor if it is provided as a perc<strong>en</strong>tage, first, and<br />

th<strong>en</strong> uses the scale() method of the matrix object:<br />

if (perc<strong>en</strong>t)<br />

{<br />

xScale = xScale / 100;<br />

yScale = yScale / 100;<br />

}<br />

sourceMatrix.scale(xScale, yScale);<br />

return sourceMatrix;<br />

The translate() method<br />

The translate() method simply applies the dx and dy translation factors by calling the translate() method of the<br />

matrix object, as follows:<br />

sourceMatrix.translate(dx, dy);<br />

return sourceMatrix;<br />

The rotate() method<br />

The rotate() method converts the input rotation factor to radians (if it is provided in degrees or gradi<strong>en</strong>ts), and th<strong>en</strong><br />

calls the rotate() method of the matrix object:<br />

if (unit == "degrees")<br />

{<br />

angle = Math.PI * 2 * angle / 360;<br />

}<br />

if (unit == "gradi<strong>en</strong>ts")<br />

{<br />

angle = Math.PI * 2 * angle / 100;<br />

}<br />

sourceMatrix.rotate(angle);<br />

return sourceMatrix;<br />

Calling the MatrixTransformer.transform() method from the application<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

The application contains a user interface for getting the transformation parameters from the user. It th<strong>en</strong> passes these<br />

values, along with the matrix property of the transform property of the display object, to the Matrix.transform()<br />

method, as follows:<br />

Last updated 6/6/2012<br />

219

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

Saved successfully!

Ooh no, something went wrong!