Search code examples
actionscript-3flashmaskmasking

as3 MovieClip masking not working


I'm having difficulties trying to add some masks

 mc1.mask = randMc;

Where mc1 = loaded MovieClip, and randMc is a pic imported to flash and converted as MovieClip. This is a very big game code I have there so I thought the Indexes might be the problem so I added this :

setChildIndex(randMc, (getChildIndex(mc1)-1));

But it didn't work meaning the movieclip stays the same, it won't mask with randMc... Any suggestions?

Note: I also have used scaleX/Y on mc1


Solution

  • it seems that .png files are a mask including transparent pixels, so it's a square mask.. anyway I fixed it with

    mc1.cacheAsBitmap  = true;
    randMc.cacheAsBitmap  = true;
    

    This way it the empty pixels won't "count" and the mask will be just like the imported .png on stage