Working with Movie Clips and Buttons > Using actions and methods to control movie clips > Using movie clips as masks

 

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 while a movie plays.

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, choose a movie clip to be masked.

2

In the Property inspector, enter an instance name for the movie clip, such as image.

3

Create a movie clip to be a mask. Give it an instance name in the Property inspector, such as mask.

4

Select frame 1 in the Timeline.

5

Choose Window > Actions to open the Actions panel if it isn't already open.

6

In the Actions toolbox (at the left of the panel), click the Objects category, the Movie category, the MovieClip category, and the Methods category, and double-click setMask.

7

In the parameters area, enter the instance name of the mask movie clip.

The code should look like this:

image.setMask(mask);

For detailed information, see MovieClip.setMask in the ActionScript Dictionary.