The preceding code is separated into three sections. The first section imports the required
classes and packages. The second section creates a nested movie clip that is used to load an
image and apply filters to the holder movie clip. The final section of code creates a new
MovieClipLoader instance and a listener for the movie clip loader. The listener object
defines a single event handler function,
successfully loads and is available on the Stage. First the image is repositioned to the center
of the Stage, then a new Tween object is created that animates the movie clip and applies a
blur filter of 0 and 10.
3.
Select Control > Test Movie to test the Flash document.
Using the clone() method
The
method within each filter class returns a new filter instance with all of the same
clone()
properties as the original filter instance. When you work with filters, you might want to make
a copy of a filter, and to do so you need to duplicate the filter using the
you do not use the clone method to duplicate a filter, Flash creates a reference to the original
filter only. If Flash creates a reference to the original filter, any change made to the duplicate
filter also modifies the original filter object.
The following procedure creates a new instance of a DropShadowFilter (
calls the
method to duplicate the green drop shadow filter, and saves a new filter
clone()
named
redDropShadow
applied to a
flower_mc
To use the clone method:
1.
Create a new Flash document, and name it clone.fla.
2.
Create a movie clip on the Stage.
3.
Select the movie clip instance, and type flower_mc in the Instance Name text box in the
Property inspector.
4.
Select Frame 1 of the Timeline, and add the following code in the Actions panel:
import flash.filters.DropShadowFilter;
var greenDropShadow:DropShadowFilter = new DropShadowFilter();
greenDropShadow.color = 0x00FF00; // green
var redDropShadow:DropShadowFilter = greenDropShadow.clone();
redDropShadow.color = 0xFF0000; // red
flower_mc.filters = [greenDropShadow, redDropShadow];
onLoadInit
. The cloned filter sets a new drop shadow color, and both filters are
movie clip instance that's on the Stage.
, that is started once the image
clone()
greenDropShadow
Manipulating filter effects with code
method. If
),
533
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?