PDA

View Full Version : Dynamic Masking Problem


05studios
08-08-2008, 10:32 PM
hey ,

I have a mask layer that contains a bunch of shapes that i want to mask out of the image below. Each shape is a unique instance name.

How can I dynamically make some of them not mask out the image anymore and how do I make them come back? I need to, under certain circumstances, have the masks in different areas.

I tried mask1_mc.visible = false, and mask1_mc.mask = null; but those don't do the trick. I have a TON of movieClips in there that need to change, so I don't want to have to use a 2 frame solution inside of each movieClip (one showing the mask, one not). I would prefer to do it all in actionscript.

Thanks so much!

SergeantFlash
08-09-2008, 12:57 AM
Make a container movie clip and put all your mask movie clips inside of that (so you will have a movie clip with a bunch of different movie clip inside of it). Set the mask of the image you want masked to the container movie clip (that contains all your mask movie clips, like mask1_mc). Now, when you want to remove one of those masks, just remove the child from the container movie clip. Just look at the example code below:
//masked_mc is the image that is being masked
//mainMask is a movie clip that contains multiple movie clips that act as masks

masked_mc.mask = mainMask; //this sets mainMask as the mask for masked_mc
//then do this to get rid of the mask you want:
mainMask.removeChild(mainMask.mask1_mc); //this removes the mask1_mc from mainMask, while the other movie clips still mask masked_mc
//or this:
mainMask.mask1_mc.x = stage.stageWidth * 2;
//or this:
mainMask.mask1_mc.scaleX = 0;
mainMask.mask1_mc.scaleY = 0;
//don't try this:
mainMask.mask1_mc.visible = false; //<-- this will not work