Kayes
Kayes

Reputation: 1096

How to use transparent BitmapData as a mask

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.

Upvotes: 5

Views: 9161

Answers (3)

eLouai
eLouai

Reputation: 696

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;

Upvotes: 9

Daniel
Daniel

Reputation: 35734

The thing you need to do is turn the bitmap caching on.

myMc.cacheAsBitmap = true; if I remember correctly ...

Upvotes: 2

PatrickS
PatrickS

Reputation: 9572

Maybe you should try using the Bitmap itself as a mask , if you need that Bitmap to show, try creating another Bitmap using the transparent BitmapData and use that as a mask.

Upvotes: 0

Related Questions