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 />

Working with motion twe<strong>en</strong>s<br />

Initializing the filters array<br />

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

The initFilters() method initializes the filters. Its first argum<strong>en</strong>t is an array of the fully qualified class names of all<br />

the filters applied to the display object. This array of filter names is g<strong>en</strong>erated from the filters list for the motion twe<strong>en</strong><br />

in Flash. In your copy of the script, you can remove or add any of the filters in the flash.filters package to this<br />

array. The following call initializes the filters list for the target display object. It applies the DropShadowFilter,<br />

GlowFilter, and BevelFilter and copies the list to each keyframe in the Motion object.<br />

__motion_Box.initFilters(["flash.filters.DropShadowFilter", "flash.filters.GlowFilter",<br />

"flash.filters.BevelFilter"], [0, 0, 0]);<br />

Adding filters<br />

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

The addFilterPropertyArray() method describes the properties of an initialized filter with the following<br />

argum<strong>en</strong>ts:<br />

1 Its first argum<strong>en</strong>t id<strong>en</strong>tifies a filter by index. The index refers to the position of the filter name in the filter class<br />

names array passed in a previous call to initFilters().<br />

2 Its second argum<strong>en</strong>t is the filter property to store for that filter in each keyframe.<br />

3 Its third argum<strong>en</strong>t is the value of the specified filter property.<br />

Giv<strong>en</strong> the previous call to initFilters(), the following calls to addFilterPropertyArray() assign a value of 5 to<br />

the blurX and blurY properties of the DropShadowFilter. The DropShadowFilter is the first (index 0) item in the<br />

initialized filters array:<br />

__motion_Box.addFilterPropertyArray(0, "blurX", [5]);<br />

__motion_Box.addFilterPropertyArray(0, "blurY", [5]);<br />

The next three calls assign values to the quality, alpha, and color properties of the GlowFilter, the second item (index<br />

1) in the initialized filter array:<br />

__motion_Box.addFilterPropertyArray(1, "quality", [BitmapFilterQuality.LOW]);<br />

__motion_Box.addFilterPropertyArray(1, "alpha", [1.00]);<br />

__motion_Box.addFilterPropertyArray(1, "color", [0xff0000]);<br />

The next four calls assign values to the shadowAlpha, shadowColor, highlightAlpha, and highlightColor of the<br />

BevelFilter, the third (index 2) item in the initialized filters array:<br />

__motion_Box.addFilterPropertyArray(2, "shadowAlpha", [1.00]);<br />

__motion_Box.addFilterPropertyArray(2, "shadowColor", [0x000000]);<br />

__motion_Box.addFilterPropertyArray(2, "highlightAlpha", [1.00]);<br />

__motion_Box.addFilterPropertyArray(2, "highlightColor", [0xffffff]);<br />

Adjusting color with the ColorMatrixFilter<br />

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

After the ColorMatrixFilter has be<strong>en</strong> initialized, you can set the appropriate AdjustColor properties to adjust the<br />

brightness, contrast, saturation, and hue of the twe<strong>en</strong>ed display object. Typically, the AdjustColor filter is applied<br />

wh<strong>en</strong> the motion twe<strong>en</strong> is created in Flash; you can fine-tune it in your copy of the ActionScript. The following<br />

example transforms the hue and saturation of the display object as it moves.<br />

Last updated 6/6/2012<br />

341

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

Saved successfully!

Ooh no, something went wrong!