Question

I am attempting to apply a mask to all objects on the stage except for a couple. There are a lot of different objects, and the amount of them will change in the future, so I want the masking to be done dynamically.

I wrote this code:

var i;

for (i = 0; i < this.numChildren; i++) {
    if (this.getChildAt(i).name!="stage_kelp_bg" && this.getChildAt(i).name!="magnifier_mask") {
        this.getChildAt(i).mask = this.magnifier_mask;
    }
}

The above code is inside the document class's constructor method. Simply stating something like:

this.stage_kelp.mask = this.magnifier_mask;

works flawlessly, but only for that one object. Any idea what's wrong?

No errors are thrown, the objects just simply don't get masked.

Was it helpful?

Solution

Further research shows me that I cannot apply 1 mask to multiple objects. I have to have a mask for each object, or put all the objects into one container and mask that container.

Apparently you can use a layer to mask multiple objects on the timeline, but you can't do it programmatically without adding all the objects to one container. Unfortunately I can't do this without re-coding the entire application, so I will be using the timeline to mask things.

OTHER TIPS

I would suggest you to better move all the movieclips to be masked in a single movieclip. This would be easier, if it's feasible in your case.

How about for each

for (var mc:movieClicp in this){
                  mc.mask=mask_}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top