topical media & game development

talk show tell print

#graphic-flex-image-effects-07-Flex-AetherTest.ax

#graphic-flex-image-effects-07-Flex-AetherTest.ax [swf] [flash] flex


  package {
  
          import aether.effects.adjustments.LevelsEffect;
          import aether.effects.adjustments.PosterizeEffect;
          import aether.effects.adjustments.SaturationEffect;
          import aether.effects.common.CompositeEffect;
          import aether.effects.convolution.FindEdgesEffect;
          import aether.effects.filters.BlurEffect;
  
          import flash.display.Bitmap;
          import flash.display.BitmapData;
          import flash.display.BlendMode;
  
          [SWF(width=360, height=576, backgroundColor=0x000000)]
  
          
Demonstrates the use of the aether effects library to alter a loaded image through the application of multiple effects combined through a CompositeEffect.

  
          public class @ax-graphic-flex-image-effects-07-Flex-AetherTest extends graphic_flex_image_effects_07_Flex_AbstractImageLoader {
  
                  
Constructor. Passes path of image to load to super class.

  
                  public function @ax-graphic-flex-image-effects-07-Flex-AetherTest() {
                          super("../../assets/Audrey.jpg");
                  }
  
                  
Run after the image loads in super class. This adds the image to the stage, then dupes it and applied a number of combined effects to the dupe using aether before adding the dupe below the original.

  
                  override protected function runPostImageLoad():void {
                          addChild(_loadedBitmap);
                          var bitmapData:BitmapData = _loadedBitmap.bitmapData.clone();
                          // CompositeEffect allows all effects to be applied at once
                          // using a single blend mode or alpha
                          new CompositeEffect(
                                  [
                                  new PosterizeEffect(),
                                  new BlurEffect(2, 2),
                                  new LevelsEffect(0, 100, 160),
                                  new SaturationEffect(.2),
                                  // a second composite it used here so that this subeffect
                                  // can be applied to the original image and then overlaid
                                  // using another blend mode
                                  new CompositeEffect(
                                          [
                                          new FindEdgesEffect(),
                                          new SaturationEffect(0),
                                          new LevelsEffect(50, 127, 200)
                                          ], bitmapData, BlendMode.SCREEN
                                  )
                                  ]
                          ).apply(bitmapData);
                          var bitmap:Bitmap = new Bitmap(bitmapData);
                          bitmap.y = bitmap.height;
                          addChild(bitmap);
                  }
  
          }
  
  }
  


(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.