gradient mask in as3

Using a gradient mask isn’t anything new but it isn’t something i haven’t used before in flash. It seems simple enough i have used this hundreds of times in photoshop it should be just as easy in flash. Well it wasn’t as easy as i thought it would be. Creating a gradient mask on the timeline just works as a regular mask as a full shape not a gradient. The only way i discovered to get this to work was to put some actionscript on the first and last frame of the timeline animation consisting of the following:

maskClip.cacheAsBitmap = true;
imgClip.cacheAsBitmap = true;
imgClip.mask = maskClip;

Where maskClip is the instance name of the gradient mask and the imgClip is the instance name of the object you are masking. So all this does is set the mask in actionscript which this is already doing in the timeline. Then caching as bitmap on both objects to store updates in memory. This causes the masking effect to recognise the gradient in use.

Comments

    Comments are currently closed