O'Reilly logo

ActionScript 3.0 Cookbook by Joey Lott, Darron Schall, Keith Peters

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Applying Basic Filters

Problem

You want to apply basic filters such as drop shadows, blurs, glows, and bevels.

Solution

Construct a new filter object and assign it to the filters array of a display object.

Discussion

The flash.filters package contains the following basic filter classes: DropShadowFilter, BlurFilter, GlowFilter, BevelFilter, GradientGlowFilter, and GradientBevelFilter. We distinguish the preceding list as basic filters because they don’t require additional display objects to apply as part of surface mapping or matrices to apply for complex transforms. Each of the basic filter classes consist of fairly straightforward properties that have straightforward effects on the display objects to which the filters are applied. For example, the DropShadowFilter class allows you to change the drop shadow offset, color, and the amount of blur applied to the shadow by way of properties (and parameters passed to the constructor).

Tip

Since basic filters are discussed in the Flash and Flex documentation, we won’t discuss unnecessary details of how to construct and change the basic properties of those classes.

Once you’ve constructed a filter object, you can apply it to a display object by using the object’s filters property. The filters property is an array of filter objects. The following applies a drop shadow to a display object called sampleSprite:

sampleSprite.filters = [new DropShadowFilter()];

When you assign an array of filters to the filters property of a display object, the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required