502
Animation, Filters, and Drawings
To modify a filter’s properties when applied to a movie clip instance:
1.
Create a new Flash document and save the file as
modifyFilter.fla
.
2.
Add the following ActionScript to Frame 1 of the Timeline:
this.createEmptyMovieClip("my_mc", 10);
// draw square
with (my_mc) {
beginFill(0xFF0000, 100);
moveTo(0, 0);
lineTo(100, 0);
lineTo(100, 100);
lineTo(0, 100);
lineTo(0, 0);
endFill();
}
my_mc._x = 100;
my_mc._y = 100;
// use default DropShadowFilter values
my_mc.filters = [new flash.filters.DropShadowFilter()];
trace(my_mc.filters[0].distance); // 4
var filter_array:Array = my_mc.filters;
filter_array[0].distance = 10;
my_mc.filters = filter_array;
trace(my_mc.filters[0].distance); // 10
The first section of this code uses the Drawing API to create a red square, and positions
the shape on the Stage. The second section of code applies a drop shadow filter to the
square. Next, the code creates a temporary array to hold the current filters to apply to the
red square on the Stage. The
distance
property of the first filter is set to 10 pixels, and
the modified filter is reapplied to the
my_mc
movie clip instance.
3.
Select Control > Test Movie to test the document.
NO
TE
Currently, no support is available for having any filters perform rotation based upon
their parent’s rotation or some sort of other rotation. The blur filter always blurs
perfectly horizontally or vertically, independently of the rotation or skew of any item
in the parent object tree.
TIP
Filtered content has the same restrictions on size as content with its
cacheAsBitmap
property set to
true
. If the author zooms in too far on the SWF file, the filters are no
longer visible when the bitmap representation is greater than 2880 pixels in either
direction. When you publish SWF files with filters, it is a good idea to disable the
zoom menu options.
Summary of Contents for FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Page 1: ...Learning ActionScript 2 0 in Flash...
Page 8: ...8 Contents...
Page 18: ...18 Introduction...
Page 30: ...30 What s New in Flash 8 ActionScript...
Page 66: ...66 Writing and Editing ActionScript 2 0...
Page 328: ...328 Interfaces...
Page 350: ...350 Handling Events...
Page 590: ...590 Creating Interaction with ActionScript...
Page 710: ...710 Understanding Security...
Page 730: ...730 Debugging Applications...
Page 780: ...780 Deprecated Flash 4 operators...
Page 830: ...830 Index...