Drop Shadow Filter

Drop Shadow Filter

Flash CS4 ActionScript 3.0 Tutorial


How to Add a Drop Shadow to an Object with Flash 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 Glow 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 Drop Shadow filter with ActionScript.

Tutorial Elements

Movie Symbol with instance name filterObj_mc


Step One

Add a Movie Symbol to the stage and select the symbol with the move tool.

Step Two

Open the Properties panel (Cmd/F3 (PC-Ctrl/F3)) and type in the name filterObj_mc for the Instance Name.

Step Three

Add a new layer called Actions.

Step Four

Option double-click (PC - Alt double-click) the keyframe in the Actions layer to open the ActionScript panel.

Step Five

Copy/Paste the following code to the ActionScript panel.

var filterVar:DropShadowFilter = new DropShadowFilter(10, 45, 0x000000, .6, 15, 16, .4, 1, false, false, false);

//DropShadowFilter Options: distance, angle, color, alpha, blurX, blurY, strength, quality, inner (true = outer, false = inner), knockout (true = knockout, false = no knockout), hideObject (true hides object but not the shadow);


Step Six

Test your movie by pressing Cmd/Return (PC - Ctrl/Enter). The Drop Shadow filter is added to your object.

Dissecting the Code

The first line establishes a new DropShadowFilter variable named filterVar.

The filter contains an array of 11 values:

10 = distance (Number)

45 = angle (Number)

0x000000 = color (uint)

.6 = alpha (Number (0-1))

15 = blurX (Number)

16 = blurY (Number)

.4 = strength (Number (0-1))

1 = quality (int (1-3))

false = Inner (Boolean (false=inner shadow, true=outer shadow))

false = knockout (Boolean (true=knockout))

false = hideObject (Boolean (true hides object but not the shadow).

The final line connects the filter variable to the object.


Stock Images