AS3- Alpha Gradient Masks

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!