User Guide
Using movie clips as masks 217
You can use movie clips with drawing methods as masks; however, as with all movie clip masks,
strokes are ignored.
To draw a shape:
1.
Use MovieClip.createEmptyMovieClip() to create an empty movie clip on the Stage.
The new movie clip is a child of an existing movie clip or of the main Timeline, as shown in
the following example:
this.createEmptyMovieClip ("triangle_mc", 1);
2.
Use the empty movie clip to call drawing methods.
The following example draws a triangle with 5-point magenta lines and no fill:
with (triangle_mc) {
lineStyle (5, 0xff00ff, 100);
moveTo (200, 200);
lineTo (300, 300);
lineTo (100, 300);
lineTo (200, 200);
}
For detailed information on these methods, see their entries in the “MovieClip class” in Flash
ActionScript Language Reference. For a sample that uses the drawing methods of the MovieClip
class, see the drawingapi.fla file in the Samples\HelpExamples directory.
Using movie clips as masks
You can use a movie clip as a mask to create a hole through which the contents of another movie
clip are visible. The mask movie clip plays all the frames in its Timeline, the same as a regular
movie clip. You can make the mask movie clip draggable, animate it along a motion guide, use
separate shapes within a single mask, or resize a mask dynamically. You can also use ActionScript
to turn a mask on and off.
You cannot use a mask to mask another mask. You cannot set the
_alpha property of a mask
movie clip. Only fills are used in a movie clip that is used as a mask; strokes are ignored.
To create a mask:
1.
On the Stage, select a movie clip to be masked.
2.
In the Property inspector, enter an instance name for the movie clip, such as image_mc.
3.
Create a movie clip to be a mask. Give it an instance name in the Property inspector, such
as
mask_mc.
The masked movie clip will be revealed under all opaque (nontransparent) areas of the movie
clip acting as the mask.
4.
Select Frame 1 in the Timeline.
5.
Open the Actions panel (Window > Development Panels > Actions) if it isn’t already open.
6.
In the Actions panel, enter the following code:
image_mc.setMask(mask_mc);
For detailed information, see MovieClip.setMask() in Flash ActionScript Language Reference.