PDA

View Full Version : Masking a MovieClip with a MovieClip


dave_reach
10-02-2007, 04:52 PM
Hi,

I know this sounds simple, using the MovieClip.setMask(maskClip) syntax - but I just can't get it to work!

I have one movieclip (which loads an image, this is the Maskee) and a second movieclip which loads an instance of an object (a filled shape). I then want to mask the image.

On Combobox Change

on(change) {
if(this.selectedItem.data != "-1") {
_root.design.mcForeground.loadMovie(_root.sFgColou r);
_root.design.mcForeground._xscale = 50;
_root.design.mcForeground._yscale = 40;


_root.design.mcMask.attachMovie(this.selectedItem. data,"design_"+_root.dCount,mcDesign.mcMask.getNextHighestDepth( ));
_root.design.mcForeground.setMask(_root.design.mcM ask);
}
}


No syntax errors are found - the only symptom is that the shape (in this case a lovely bunny) doesn't mask the background (a picture of a carpet).

I was playing around with the .setMask method earlier and it worked perfectly. I'm not sure what I'm missing, and would really love any advice! Apologies if I'm being rather stupid!

The Results:
24232

Thanks,
Dave.

xxneon
10-02-2007, 05:06 PM
since your using loadMovie to load the image of the carpet in .. you can't set the mask till after the image is initialized.. if you set the mask right after the loadMovie call.. it gets .. 'erased' .. is the best way to put it i guess..

so you need to have a way of listening to see when the image is loaded and initialized.. check out using the MovieClipLoader class .. it has event handlers to handle when an image is loaded in completely .. and then you could set your mask after the image is completely downloaded..

the other alternative is creating a small function to watch the download progress of the image that is being loaded in with loadMovie.. and then when a condition is met .. (loaded bytes == total bytes) for example .. then set the mask ..

dave_reach
10-02-2007, 06:27 PM
Ahhh, perfect mate. I'll get on that tomorrow.

Cheers,
Dave.