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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

Using the drawing API<br />

The easiest way to define the matrix is by using the Matrix class’s createGradi<strong>en</strong>tBox() method, which creates a<br />

matrix that is used to define the gradi<strong>en</strong>t. You define the scale, rotation, and position of the gradi<strong>en</strong>t using the<br />

parameters passed to the createGradi<strong>en</strong>tBox() method. The createGradi<strong>en</strong>tBox() method accepts the following<br />

parameters:<br />

Gradi<strong>en</strong>t box width: the width (in pixels) to which the gradi<strong>en</strong>t will spread<br />

Gradi<strong>en</strong>t box height: the height (in pixels) to which the gradi<strong>en</strong>t will spread<br />

Gradi<strong>en</strong>t box rotation: the rotation (in radians) that will be applied to the gradi<strong>en</strong>t<br />

Horizontal translation: how far (in pixels) the gradi<strong>en</strong>t is shifted horizontally<br />

Vertical translation: how far (in pixels) the gradi<strong>en</strong>t is shifted vertically<br />

For example, consider a gradi<strong>en</strong>t with the following characteristics:<br />

Gradi<strong>en</strong>tType.LINEAR<br />

Two colors, gre<strong>en</strong> and blue, with the ratios array set to [0, 255]<br />

SpreadMethod.PAD<br />

InterpolationMethod.LINEAR_RGB<br />

The following examples show gradi<strong>en</strong>ts in which the rotation parameter of the createGradi<strong>en</strong>tBox() method<br />

differs as indicated, but all other settings stay the same:<br />

width = 100;<br />

height = 100;<br />

rotation = 0;<br />

tx = 0;<br />

ty = 0;<br />

width = 100;<br />

height = 100;<br />

rotation = Math.PI/4; // 45°<br />

tx = 0;<br />

ty = 0;<br />

width = 100;<br />

height = 100;<br />

rotation = Math.PI/2; // 90°<br />

tx = 0;<br />

ty = 0;<br />

The following examples show the effects on a gre<strong>en</strong>-to-blue linear gradi<strong>en</strong>t in which the rotation, tx, and ty<br />

parameters of the createGradi<strong>en</strong>tBox() method differ as indicated, but all other settings stay the same:<br />

Last updated 6/6/2012<br />

227

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

Saved successfully!

Ooh no, something went wrong!