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 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 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); } } }