EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Using Filter Effects

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
498 Animation, Filters, and Drawings
Using filter effects
Filters are visual effects that you can apply to objects rendered at runtime by Flash Player, such
as movie clip instances. The filters include drop shadow, blur, glow, bevel, gradient glow, and
gradient bevel. You can also use an adjust color filter that lets you edit a movie clips
brightness, contrast, saturation, and hue. You can apply filters using the Flash user interface in
Flash Professional 8, or using ActionScript in Flash Basic 8 or Flash Professional 8.
You can apply each of these filter effects to movie clips, buttons, or text fields by using either
the Filters tab in the Property inspector or by using ActionScript. If you use ActionScript to
apply the filters to an instance, you can also use a displacement map filter (see “Using the
displacement map filter” on page 528) or a convolution filter (see “Using the convolution
filter” on page 527). These filters are applied to the vector definitions, so there is no overhead
of storing a bitmap image within the SWF file. You can also write ActionScript that lets you
modify an existing filter that you applied to a text field, movie clip, or button.
The following procedure demonstrates how you could use an
onEnterFrame event handler to
animate a glow filter effect on a movie clip.
To animate a filter effect applied to a movie clip instance:
1. Create a new Flash document and save it as animFilter.fla.
2. Add the following ActionScript to Frame 1 of the Timeline:
this.createEmptyMovieClip("box_mc", 10);
box_mc.lineStyle(20, 0x000000);
box_mc.beginFill(0x000000);
box_mc.moveTo(0, 0);
box_mc.lineTo(160, 0);
box_mc.lineTo(160, 120);
box_mc.lineTo(0, 120);
box_mc.lineTo(0, 0);
box_mc.endFill();
box_mc._x = 100;
box_mc._y = 100;
box_mc.filters = [new flash.filters.GlowFilter()];
var dir:Number = 1;
box_mc.blur = 10;
box_mc.onEnterFrame = function() {
box_mc.blur += dir;
if ((box_mc.blur >= 30) || (box_mc.blur <= 10)) {
dir *= -1;
}
var filter_array:Array = box_mc.filters;
filter_array[0].blurX = box_mc.blur;
filter_array[0].blurY = box_mc.blur;
box_mc.filters = filter_array;
};

Table of Contents

Related product manuals