How to use transparent BitmapData as a mask

Kayes picture Kayes · Sep 15, 2010 · Viewed 9.1k times · Source

I have a BitmapData object created dynamically that contains user-drawn shapes. I then attach that BitmapData object to a MovieClip via a Bitmap object and set that MovieClip as a mask to another MovieClip. The mask works but the whole bounding rectangle of the BitmapData is acting as the mask. But I want to exclude the transparent portion from the mask so only user-drawn shape can be set as mask. Can anyone tell how to achieve that? Thanks.

Answer

eLouai picture eLouai · Oct 3, 2011

I see you already solved it (in the comments section). Posting it as an answer.
Set BOTH movieclip and mask cacheAsBitmap to true.

i.e.:

movieclip.cacheAsBitmap = true;  
movieclip_mask.cacheAsBitmap = true;