简体   繁体   中英

Masking with transparent PNG in AS3

i want to mask objects with dynamic transparent PNG files in Flash Action Script 3.0

if you have any solution regrading that please forward..

Thank you, Hardik

I take it that by dynamic PNG you just mean one that has been loaded by code at run time. There is nothing special to that, the same answer applies as to any library object imported as a Bitmap and then set to use lossless compression.

In order to do this the png to be used as a mask must be embedded in a DisplayObject (typically a Sprite, a MovieClip or even a Loader). The DisplayObject class has a property cacheAsBitmap and you need to set that property to true for both the DisplayObject holding the mask and the one holding the content to be masked. Then assign the mask by code to let the mask reveal the content.

Example:

//myClip is the MovieClip or Sprite or even Loader holding the content
myClip.cacheAsBitmap=true;
//myMask is a MovieClip or Sprite or even Loader containing the transparent PNG
myMask.cacheAsBitmap=true;

//set up the mask to reveal the content where the PNG is not transparent
myClip.mask=maskClip;

PhotonStorm有一个实现 ,你可以挖掘并弄清楚他们是如何做到的。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM