![](https://pdfstore-manualsonline.prod.a.ki/pdfasset/2/38/2388e2db-29fd-4cb4-ba34-dd210e2d1db6/2388e2db-29fd-4cb4-ba34-dd210e2d1db6-bg58.png)
Macromedia MAX 2005 - Anaheim, CA What’s New In Flash 8
88
Programming Filters
Working with filters using ActionScript
The flash.filters package contains classes for the bitmap filter effects that are new in Flash Player 8.
Filters let you use ActionScript to apply rich visual effects, such as blur, bevel, glow, and drop
shadow, to text, movie clip, and button instances. You can also use the Flash authoring tool to apply
filter effects to objects such as text, images, and video. Flash has nine filter effects, although only
seven are accessible by using the user interface in Flash Professional 8. The ConvolutionFilter and
DisplacementMapFilter filters are only available by using ActionScript code.
NOTE:
All filters are availabe by using ActionScript in both Flash Basic 8 and Flash Professional 8
The following procedure loads a semitransparent PNG image, and applies a GlowFilter effect to the
nontransparent portion of the image.
To apply filters to semitransparent images:
1. Create a new Flash document and save it as transparentImg.fla.
2. Add the following ActionScript to Frame 1 of the Timeline:
import flash.filters.GlowFilter;
System.security.allowDomain("http://www.helpexamples.com");
var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip) {
target_mc._x = (Stage.width - target_mc._width) / 2;
target_mc._y = (Stage.height - target_mc._height) / 2;
var glow:GlowFilter = new GlowFilter();
target_mc.filters = [glow];
};
this.createEmptyMovieClip("img_mc", 10);
var img_mcl:MovieClipLoader = new MovieClipLoader();
img_mcl.addListener(mclListener);
img_mcl.loadClip("http://www.helpexamples.com/flash/images/logo.p
ng", img_mc);
This code uses a movie clip loader instance to load a semi-transparent PNG image. After the
image finishes loading, the image moves to the center of the Stage and a glow filter is
applied.
3. Select Control > Test Movie to test the document.
The glow filter effect is only applied to the opaque (nontransparent) area of the PNG image.