//TODO: not blending package { import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.BitmapDataChannel; import flash.display.Sprite; import flash.events.Event; import flash.geom.Point; import flash.display.BlendMode; /** * ... * @author John del Rosario */ public class Main extends Sprite { [Embed(source="../lib/image1.jpg")] //I just embedded my image. private var Turtle:Class; private var image:Bitmap; //Bitmap for source image private var bmd:BitmapData; //BitmapData from source image //Bitmaps for the different channels so we could control them private var r:Bitmap; private var g:Bitmap; private var b:Bitmap; private var rAngle:Number; private var gAngle:Number; public function Main():void { if (stage) init(); else addEventListener(Event.ADDED_TO_STAGE, init); } private function init(e:Event = null):void { removeEventListener(Event.ADDED_TO_STAGE, init); // entry point rAngle = gAngle = 0; initImage(); } private function initImage():void { image = new Turtle(); bmd = image.bitmapData; //get the bitmapdata of the source image seperate(); addEventListener(Event.ENTER_FRAME, onEnterFrame, false, 0, true); } private function seperate():void { //seperates the RGB channels and puts them in individual Bitmaps var blue:BitmapData = new BitmapData(image.width, image.height, true, 0xFF000000); //bitmapdata for blue channel var green:BitmapData = new BitmapData(image.width, image.height, true, 0xFF000000); //bitmapdata for green channel var red:BitmapData = new BitmapData(image.width, image.height, true, 0xFF000000); //bitmapdata for red channel //get the different channels blue.copyChannel(bmd, bmd.rect, new Point(0, 0), BitmapDataChannel.BLUE, BitmapDataChannel.BLUE); green.copyChannel(bmd, bmd.rect, new Point(0, 0), BitmapDataChannel.GREEN, BitmapDataChannel.GREEN); red.copyChannel(bmd, bmd.rect, new Point(0, 0), BitmapDataChannel.RED, BitmapDataChannel.RED); //assign the channels to their individual Bitmaps b = new Bitmap(blue); g = new Bitmap(green); r = new Bitmap(red); addChild(r); addChild(g); addChild(b); //set the blend mode. very important. //NOTE: make sure the background is BLACK. Other colors give different results. White just shows white. r.blendMode = BlendMode.SCREEN; g.blendMode = BlendMode.SCREEN; b.blendMode = BlendMode.SCREEN; } private function onEnterFrame(e:Event):void { rAngle += 10; gAngle -= 10; if (rAngle > 360) rAngle = 0; if (gAngle > 360) gAngle = 0; r.x = Math.cos(rAngle * Math.PI / 180) * 5; r.y = Math.sin(rAngle * Math.PI / 180) * 5; g.x = Math.cos(gAngle * Math.PI / 180) * 2; g.y = Math.sin(gAngle * Math.PI / 180) * 5; } } }