You would think these days that you could easily hop on the timeline to create a mask with an alpha property. Well, it’s not that easy and i suggest using code. Especially the more advanced you want your masks to be.
First lay out your “masker” and “maskee” on the stage like you normally would to make a mask. (STOP! DO NOT go to the layers and right click and click “Mask”.)
Now hop to the actions panel to write some code:
- First, make sure everything has an instance name on the stage and they’re all movie clips.
- Whatever objects you are using to create the mask….you must cache them all as bitmaps:
instanceName1.cacheAsBitmap = true;
instanceName2.cacheAsBitmap = true;
instanceName3.cacheAsBitmap = true;
etc…- Now you must apply the mask to your graphic:
instanceName1.mask = instanceName2;
THAT’S IT!!! To get special graphic effects while using a mask, you MUST apply the mask using code rather then in the layers on the timeline.
Now hop on the timeline and animate your masks or you can code your animations like you normally would!
Remember: You can only do a mask with advanced graphics(gradients, filters, blurs, alpha) by using the above code IT WILL NOT WORK GOOD ON THE TIMELINE. There may be a round about way out there, but this is the best and simplest way!
Filed under: Actionscript 3.0, Dynamic Tagged: | advanced mask, alpha mask, alpha mask as3, as3 mask, bitmap mask, blur mask, cache mask, cacheAsBitmap, custom mask, dynamic mask, filter mask, gradient mask, mask, mask gradient as3, masker maskee, special mask
Thanks!!! I was trying do this a long time, and just your method worked
Very Simple and functional!
Congratulations!
thanks a lot, much simpler than anything else I have tried
I have been trying to figure this out for hours, everybody else seems to be saying to use this function
instanceName1.setMask(“instanceName2″);
but it does not work for me. Thanks for your solution!
Thanks! this does the trick
this is amazing. i couldn’t figure out how to do this, but now, not only does this work, it is about 2 lines of code! Much easier than doing even the standard layer mask.. if you are a fast typer
Thanks!
Thank you, I’ve been searching for this for ages. It seems like such a simple task to do. Why does flash have to be so user unfriendly at times lol?
thanks man!,
i used that code then applied a blurFilter to the mask. and although the blur works wonderful, everything inside the mask that should be 100% visible, is half-transparent…
any ideas why?
thanks
Phonish: the “setMask” function was depricated in CS3 (works in earlier version, but not current).
Masking works, but no gradient alpha is used! Just the entire alphagradient clip works as a mask, still with hard lines.
In a case like this, you would have to change one of the gradient color’s alpha value. Something like 40% to see the results: i.e. white: 100% / black 40%
Very helpful. Thanks for sharing.
yeah so, what about 100% coded flash, … ill post the answer to that one on my own blog, thanks for your contribution though
Thanks for the refresher. For some reason, I always forget how to do this, no matter how many times I do it.
Thanks for sharing,
was missed out a step and you just solved my problem
THANKS U !!!!! that’s work !!
Very handy to know this – thanks
Can’t get it to work using CS4 and AS2.