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

Filtering display objects<br />

Blur filter<br />

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

The BlurFilter class smears, or blurs, a display object and its cont<strong>en</strong>ts. Blur effects are useful for giving the impression<br />

that an object is out of focus or for simulating fast movem<strong>en</strong>t, as in a motion blur. By setting the quality property of<br />

the blur filter too low, you can simulate a softly out-of-focus l<strong>en</strong>s effect. Setting the quality property to high results<br />

in a smooth blur effect similar to a Gaussian blur.<br />

The following example creates a circle object using the drawCircle() method of the Graphics class and applies a blur<br />

filter to it:<br />

import flash.display.Sprite;<br />

import flash.filters.BitmapFilterQuality;<br />

import flash.filters.BlurFilter;<br />

// Draw a circle.<br />

var redDotCutout:Sprite = new Sprite();<br />

redDotCutout.graphics.lineStyle();<br />

redDotCutout.graphics.beginFill(0xFF0000);<br />

redDotCutout.graphics.drawCircle(145, 90, 25);<br />

redDotCutout.graphics.<strong>en</strong>dFill();<br />

// Add the circle to the display list.<br />

addChild(redDotCutout);<br />

// Apply the blur filter to the rectangle.<br />

var blur:BlurFilter = new BlurFilter();<br />

blur.blurX = 10;<br />

blur.blurY = 10;<br />

blur.quality = BitmapFilterQuality.MEDIUM;<br />

redDotCutout.filters = [blur];<br />

Drop shadow filter<br />

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

Drop shadows give the impression that there is a separate light source situated above a target object. The position and<br />

int<strong>en</strong>sity of this light source can be modified to produce a variety of differ<strong>en</strong>t drop shadow effects.<br />

The DropShadowFilter class uses an algorithm that is similar to the blur filter’s algorithm. The main differ<strong>en</strong>ce is that<br />

the drop shadow filter has a few more properties that you can modify to simulate differ<strong>en</strong>t light-source attributes (such<br />

as alpha, color, offset and brightness).<br />

The drop shadow filter also allows you to apply custom transformation options on the style of the drop shadow,<br />

including inner or outer shadow and knockout (also known as cutout) mode.<br />

The following code creates a square box sprite and applies a drop shadow filter to it:<br />

Last updated 6/6/2012<br />

277

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

Saved successfully!

Ooh no, something went wrong!