Learning ActionScript 2.0 in Adobe Flash |
|
|
|
| Working with Movie Clips > 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:This instance is your mask.
The masked movie clip is revealed under all opaque (nontransparent) areas of the movie clip acting as the mask.
System.security.allowDomain("http://www.helpexamples.com");
this.createEmptyMovieClip("img_mc", 10);
var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip):Void {
target_mc.setMask(mask_mc);
}
var my_mcl:MovieClipLoader = new MovieClipLoader();
my_mcl.addListener(mclListener);
my_mcl.loadClip("http://www.helpexamples.com/flash/images/image1.jpg", img_mc);
An external JPEG image loads into the SWF file at runtime, and is masked by the shape you drew previously on the Stage.
For detailed information, see setMask (MovieClip.setMask method) in the ActionScript 2.0 Language Reference.
|
|
|
|