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, just like 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
movie clip. Only fills are used in a movie clip that is used as a mask; strokes are ignored.
To create a mask:
On the Stage, select a movie clip to be masked.
1
In the Property inspector, enter an instance name for the movie clip, such as
2
Create a movie clip to be a mask. Give it an instance name in the Property inspector, such
3
as
.
mask
The masked movie clip will be revealed under all opaque (nontransparent) areas of the movie
clip acting as the mask.
Select Frame 1 in the Timeline.
4
Open the Actions panel (Window > Development Panels > Actions) if it isn't already open.
5
In the Actions panel, enter the following code:
6
image.setMask(mask);
For detailed information, see
About masking device fonts
You can use a movie clip to mask text that is set in a device font. In order for a movie clip mask on
a device font to work properly, the user must have Flash Player 6 release 40 or later.
When you use a movie clip to mask text set in a device font, the rectangular bounding box of the
mask is used as the masking shape. That is, if you create a nonrectangular movie clip mask for
device font text in the Flash authoring environment, the mask that appears in the SWF file will be
the shape of the rectangular bounding box of the mask, not the shape of the mask itself.
You can mask device fonts only by using a movie clip as a mask. You cannot mask device fonts by
using a mask layer on the Stage.
Handling movie clip events
Movie clips can respond to user events, such as mouse clicks and keypresses, as well as system-level
events, such as the initial loading of a movie clip on the Stage. ActionScript provides two ways to
handle movie clip events: through event handler methods and through
event handlers. For more information, see
132
Chapter 7: Working with Movie Clips
MovieClip.setMask()
Chapter 4, "Handling Events," on page
property of a mask
_alpha
on page
533.
onClipEvent()
.
image
and
on()
83.
Need help?
Do you have a question about the FLASH MX 2004 - ACTIONSCRIPT and is the answer not in the manual?
Questions and answers