package { import aether.effects.ImageEffect; import flash.display.BitmapData; import flash.geom.Point; /** * Demonstrates how aether's ImageEffect may be extended to create visual effects. * This effect allows you to use pixelDissolve on an image and set the effect's opacity * and blend mode. Making it an ImageEffect means it can be included in composites. */ public class graphic_flex_image_effects_10_Flex_DissolveEffect extends ImageEffect { private var _amount:Number; private var _color:uint; /** * Constructor. Sets the properties of the effect. * * @param amount The amount of dissolve to apply, between 0 and 1. * @param color The color to use in the dissolve effect. * @param blendMode The blend mode to use when applying the effect. * @param alpha The alpha to use when applying the effect. */ public function graphic_flex_image_effects_10_Flex_DissolveEffect( amount:Number=.5, color:uint=0xFFFFFFFF, blendMode:String=null, alpha:Number=1 ) { init(blendMode, alpha); _amount = amount; _color = color; } /** * Applies the effect to the specified image. * * @param bitmapData The image to which to apply the effect. */ override protected function applyEffect(bitmapData:BitmapData):void { var numPixels:uint = (bitmapData.width*bitmapData.height)*_amount; bitmapData.pixelDissolve( bitmapData, bitmapData.rect, new Point(), 0, numPixels, _color ); } } }