Monday, April 30, 2007

Blend Modes as a Mask

today i ran into a problem with gradient masks. the problem seems to be that flash 8 does not appreciate a mask using a gradient to be itself masked by anything else. the effect that such a combination produces is a flickering of stage assets akin to compiling with an error in your code. after much experimentation i google'd something that led me to using the blend mode instead of cacheasbitmap/setmask. it works perfectly and is not a big deal to set up.

take your gradient mask symbol and change the blendmode to alpha (from the post i read erase works too but i haven't tried it since alpha worked). you can change the blendmode in a couple of ways. one way is in the flash ide. there is a blend mode drop down on the properties of the movieclip. another way is by code. reference the movieclip's blendMode property and assign it the string 'alpha'.

MovieClip.blendMode = 'alpha';

place the movieclip / shape being masked on a layer below your 'mask' but do not set either layer as a mask layer.

convert these two layers into its own movieclip.

set the blendmode of this combined movieclip to 'layer' using either of the above methods.

MovieClip.blendMode = 'layer';

if you used the ide to set the blend modes then you will be able to see the effect immediately. if you used code you'll have to compile.