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

If the shader defines more that one input image, the additional inputs must be specified manually (that is, by setting<br />

the input property of any ShaderInput instance that belongs to the Shader instance).<br />

Once you have a Shader object for your shader, you create a ShaderFilter instance. This is the actual filter object that<br />

you use like any other filter. To create a ShaderFilter that uses a Shader object, call the ShaderFilter() constructor<br />

and pass the Shader object as an argum<strong>en</strong>t, as shown in this listing:<br />

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

For a complete example of using a shader filter, see “Using a shader as a filter” on page 318.<br />

Filtering display objects example: Filter Workb<strong>en</strong>ch<br />

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

The Filter Workb<strong>en</strong>ch provides a user interface to apply differ<strong>en</strong>t filters to images and other visual cont<strong>en</strong>t and see the<br />

resulting code that can be used to g<strong>en</strong>erate the same effect in ActionScript. In addition to providing a tool for<br />

experim<strong>en</strong>ting with filters, this application demonstrates the following techniques:<br />

Creating instances of various filters<br />

Applying multiple filters to a display object<br />

To get the application files for this sample, see www.adobe.com/go/learn_programmingAS3samples_flash. The Filter<br />

Workb<strong>en</strong>ch application files can be found in the Samples/FilterWorkb<strong>en</strong>ch folder. The application consists of the<br />

following files:<br />

File Description<br />

com/example/programmingas3/filterWorkb<strong>en</strong>ch/FilterWorkb<strong>en</strong>chController.as Class that provides the main functionality of the<br />

application, including switching cont<strong>en</strong>t to which<br />

filters are applied, and applying filters to cont<strong>en</strong>t.<br />

com/example/programmingas3/filterWorkb<strong>en</strong>ch/IFilterFactory.as Interface defining common methods that are<br />

implem<strong>en</strong>ted by each of the filter factory classes.<br />

This interface defines the common functionality that<br />

the FilterWorkb<strong>en</strong>chController class uses to interact<br />

with the individual filter factory classes.<br />

in folder com/example/programmingas3/filterWorkb<strong>en</strong>ch/:<br />

BevelFactory.as<br />

BlurFactory.as<br />

ColorMatrixFactory.as<br />

ConvolutionFactory.as<br />

DropShadowFactory.as<br />

GlowFactory.as<br />

Gradi<strong>en</strong>tBevelFactory.as<br />

Gradi<strong>en</strong>tGlowFactory.as<br />

Last updated 6/6/2012<br />

Set of classes, each of which implem<strong>en</strong>ts the<br />

IFilterFactory interface. Each of these classes<br />

provides the functionality of creating and setting<br />

values for a single type of filter. The filter property<br />

panels in the application use these factory classes to<br />

create instances of their particular filters, which the<br />

FilterWorkb<strong>en</strong>chController class retrieves and<br />

applies to the image cont<strong>en</strong>t.<br />

com/example/programmingas3/filterWorkb<strong>en</strong>ch/IFilterPanel.as Interface defining common methods that are<br />

implem<strong>en</strong>ted by classes that define the user<br />

interface panels that are used to manipulate filter<br />

values in the application.<br />

292

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

Saved successfully!

Ooh no, something went wrong!