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

Filtering display objects<br />

Creating and applying filters<br />

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

Filters allow you to apply a range of effects to bitmap and display objects, ranging from drop shadows to bevels and<br />

blurs. Each filter is defined as a class, so applying filters involves creating instances of filter objects, which is no differ<strong>en</strong>t<br />

from constructing any other object. Once you’ve created an instance of a filter object, it can easily be applied to a<br />

display object by using the object’s filters property, or in the case of a BitmapData object, by using the<br />

applyFilter() method.<br />

Creating a filter<br />

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

To create a filter object, simply call the constructor method of your selected filter class. For example, to create a<br />

DropShadowFilter object, use the following code:<br />

import flash.filters.DropShadowFilter;<br />

var myFilter:DropShadowFilter = new DropShadowFilter();<br />

Although not shown here, the DropShadowFilter() constructor (like all the filter classes’ constructors) accepts<br />

several optional parameters that can be used to customize the appearance of the filter effect.<br />

Applying a filter<br />

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

Once you've constructed a filter object, you can apply it to a display object or a BitmapData object; how you apply the<br />

filter dep<strong>en</strong>ds on the object to which you’re applying it.<br />

Applying a filter to a display object<br />

Wh<strong>en</strong> you apply filter effects to a display object, you apply them through the filters property. The filters<br />

property of a display object is an Array instance, whose elem<strong>en</strong>ts are the filter objects applied to the display object. To<br />

apply a single filter to a display object, create the filter instance, add it to an Array instance, and assign that Array object<br />

to the display object’s filters property:<br />

Last updated 6/6/2012<br />

268

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

Saved successfully!

Ooh no, something went wrong!