topical media & game development

talk show tell print

#graphic-flex-image-effects-10-Flex-DissolveEffect.ax

#graphic-flex-image-effects-10-Flex-DissolveEffect.ax [swf] [flash] flex


  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 @ax-graphic-flex-image-effects-10-Flex-DissolveEffect extends ImageEffect {
  
                  private var _amount:Number;
                  private var _color:uint;
  
                  
Constructor. Sets the properties of the effect.
parameter: amount The amount of dissolve to apply, between 0 and 1.
parameter: color The color to use in the dissolve effect.
parameter: blendMode The blend mode to use when applying the effect.
parameter: alpha The alpha to use when applying the effect.

  
                  public function @ax-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.
parameter: 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
                          );
                  }
  
          }
  
  }
  


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.