ActionScript 2.0 Language Reference |
|
|
|
| ActionScript classes > MovieClip > setMask (MovieClip.setMask method) | |||
public setMask(mc:Object) : Void
Makes the movie clip in the mc parameter a mask that reveals the calling movie clip.
The setMask() method allows multiple-frame movie clips with complex, multilayered content to act as masks (which is possible by using mask layers). If you have device fonts in a masked movie clip, they are drawn but not masked. You can't set a movie clip to be its own mask; for example, my_mc.setMask(my_mc).
To mask multiple objects with setMask(), place those objects within a containing movie clip and then mask the container movie clip, or use the global property this. For example, if you have movie clips in your library with Linkage Identifiers "theMaskee1_mc" and "theMaskee2_mc" and "circleMask_mc", you can use the following ActionScript (note that the instance depths must be different):
this.attachMovie("theMaskee1_mc", "theMaskee1_instance", 10,{_x:200, _y:100});
this.attachMovie("theMaskee2_mc", "theMaskee2_instance", 20,{_x:200, _y:200});
this.attachMovie("circleMask_mc", "circleMask_instance", 30 ,{_x:200, _y:150});
this.setMask(circleMask_instance);
If you create a mask layer that contains a movie clip and then apply the setMask() method to it, the setMask() call takes priority and this is not reversible. For example, you could have a movie clip in a mask layer called UIMask that masks another layer that contains another movie clip called UIMaskee. If, as the SWF file plays, you call UIMask.setMask(UIMaskee), from that point on, UIMask is masked by UIMaskee.
To cancel a mask created with ActionScript, pass the value null to the setMask() method. The following code cancels the mask without affecting the mask layer in the timeline.
UIMask.setMask(null);
You can extend the methods and event handlers of the MovieClip class by creating a subclass.
Availability: ActionScript 1.0; Flash Player 6
mc:Object - The instance name of a movie clip to be a mask. This can be a String or a MovieClip.
The following code uses the circleMask_mc movie clip to mask the theMaskee_mc movie clip:
theMaskee_mc.setMask(circleMask_mc);
|
|
|
|