Flash CS4 ActionScript 3.0 Tutorial
How to Add Glow to a Flash Object with ActionScript
Filters can be added to Movie Symbols and Text objects in Flash with the Properties panel. They can also be added to an object with ActionScript. You can choose from several different filters. For information on all the filters available, see topics, Bevel Filter, Blur Filter, and Drop Shadow Filter. Another advantage to creating filters this way is that you can create the filter once, then apply it to multiple objects.
This tutorial is an example of applying the Bevel filter with ActionScript.
Movie Symbol with instance name filterObj_mc
Add a Movie Symbol to the stage and select the symbol with the Selection tool (v key).
Open the Properties panel (Cmd/F3 (PC-Ctrl/F3)) and type in the name filterObj_mc for the Instance Name.
Add a new layer called Actions.
Option double-click (PC - Alt double-click) the keyframe in the Actions layer to open the ActionScript panel.
Copy/Paste the following code to the ActionScript panel.
var filterVar:GlowFilter = new GlowFilter(0xFFFF99, 1, 30, 40, 2, 3, false, false);
//GlowFilter Options: color, alpha, blurX, blurY, strength, quality, type (true = inner, false = outer), knockout (true = knockout, false = no knockout);
Test your movie by pressing Cmd/Return (PC - Ctrl/Enter). The Glow filter is added to your object.
Dissecting the Code
The first line establishes a new GlowFilter variable named filterVar.
The filter contains an array of 8 values:
0xFFFF99 = color (uint)
1 = alpha (Number (0-1))
30 = blurX (Number)
40 = blurY (Number)
2 = strength (Number (2=200%, .5=50%)))
3 = quality (int (1-3))
false = type (Boolean (true=inner, false=outer))
false = knockout (Boolean (true=knockout))
The final line connects the filter variable to the object.