topical media & game development
#graphic-flex-image-effects-10-Flex-LadyInRed.ax
#graphic-flex-image-effects-10-Flex-LadyInRed.ax
[swf]
[flash]
flex
package {
import aether.effects.adjustments.GradientMapEffect;
import aether.effects.adjustments.LevelsEffect;
import aether.effects.adjustments.SaturationEffect;
import aether.effects.common.CompositeEffect;
import aether.effects.shaders.ShaderEffect;
import aether.utils.ImageUtil;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.events.Event;
[SWF(width=920, height=630, backgroundColor=0xFFFFFF)]
Applies IsolateColorEffect custom shader to isolate a single color in a loaded image,
making all other pixels grayscale, then applies additional effects to create a noir
comic image.
public class @ax-graphic-flex-image-effects-10-Flex-LadyInRed extends graphic_flex_image_effects_10_Flex_AbstractImageLoader {
private var _shaderEffect:graphic_flex_image_effects_10_Flex_IsolateColorEffect;
Constructor. Passes path of asset to load to super class.
public function @ax-graphic-flex-image-effects-10-Flex-LadyInRed() {
super("graphic-flex-image-effects-10-assets-ladyInRed.jpg");
}
Handler for when image loads in super class. This initiates load of external shader file.
override protected function runPostImageLoad():void {
ShaderEffect.shaderFilePath = "graphic-flex-image-effects-10-assets-";
_shaderEffect = new graphic_flex_image_effects_10_Flex_IsolateColorEffect(0x00FF00, 20, 120, true);
_shaderEffect.addEventListener(Event.COMPLETE, onShaderReady);
}
Handler for when the shader file has loaded. This applies a composite effect, including
the shader, to the previously loaded image.
parameter: event Event dispatched by ShaderEffect.
private function onShaderReady(event:Event):void {
_shaderEffect.removeEventListener(Event.COMPLETE, onShaderReady);
addChild(_loadedBitmap);
// applies composite effect to clone of loaded bitmap image
var bitmapData:BitmapData = ImageUtil.getBitmapData(_loadedBitmap);
new CompositeEffect(
[
new SaturationEffect(0),
new CompositeEffect(
[
_shaderEffect,
new GradientMapEffect([0, 0xFF0000], [0, 255])
],
bitmapData
),
new LevelsEffect(60, 62, 64)
]
).apply(bitmapData);
// adds altered image to the right of original image
var bitmap:Bitmap = new Bitmap(bitmapData);
bitmap.x = bitmap.width;
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.