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.
How to use transparent BitmapData as a mask
Asked Answered
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;
The thing you need to do is turn the bitmap caching on.
myMc.cacheAsBitmap = true;
if I remember correctly ...
As said above, do this on the bitmap object as well. –
Vermifuge
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.
Tried setting the Bitmap directly as the mask. No luck! –
Nonary
Have you tried playing with BlendMode ( forgetting about the mask I mean )? –
Jornada
Well, I've done it! We must set the 'cacheAsBitmap' property of both the Bitmap (that will act as the mask) and the MovieClip (on which the mask will be set) to 'true'. Otherwise the mask won't work properly. –
Nonary
Thanks to this post: blog.mattiasnorell.com/2010/04/16/… –
Nonary
Thanks mate for keeping in touch with me :) –
Nonary
@Kayes, thanks a lot, you should add your own solution as an answer and accept it. –
Augustin
© 2022 - 2024 — McMap. All rights reserved.