In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

SeparationRGB (3)

SeparationRGB (3)
Get Adobe Flash player
by ProjectNya 06 Oct 2010
    Embed
/**
 * Copyright ProjectNya ( http://wonderfl.net/user/ProjectNya )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/luyv
 */

////////////////////////////////////////////////////////////////////////////////
// SeparationRGB (3)
////////////////////////////////////////////////////////////////////////////////

package {

    import flash.display.Sprite;
    import flash.display.Loader;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.BitmapDataChannel;
    import flash.display.BlendMode;
    import flash.events.Event;
    import flash.net.URLRequest;
    import flash.geom.Matrix;
    import flash.geom.Point;
    import flash.system.LoaderContext;

    [SWF(backgroundColor="#000000", width="465", height="465", frameRate="30")]

    public class Main extends Sprite {
        private var loader:Loader;
        private var content:Bitmap;
        private var bitmap:Bitmap;
        private var bitmapData:BitmapData;
        private static var basePath:String = "http://assets.wonderfl.net/images/related_images/";
        private static var photoPath:String = "b/b9/b903/b903a19502c9c61a3eac08d38e3e3ed5838f6dc8";

        public function Main() {
            //Wonderfl.capture_delay(1);
            init();
        }

        private function init():void {
            graphics.beginFill(0x000000);
            graphics.drawRect(0, 0, 465, 465);
            graphics.endFill();
            //
            loader = new Loader();
            loader.contentLoaderInfo.addEventListener(Event.INIT, initialize, false, 0, true);
            //loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete, false, 0, true);
            loader.load(new URLRequest(basePath + photoPath), new LoaderContext(true));
            //
            bitmapData = new BitmapData(300, 300, false, 0xFF000000);
            bitmap = new Bitmap(bitmapData);
            bitmap.x = 22;
            bitmap.y = 22;
            addChild(bitmap);
        }
        private function initialize(evt:Event):void {
            content = evt.target.content;
            var bd:BitmapData = content.bitmapData;
            var bw:Number = 300/bd.width;
            var bh:Number = 300/bd.height;
            var scale:Number = Math.min(bw, bh);
            var matrix:Matrix = new Matrix();
            matrix.scale(scale, scale);
            bitmapData.draw(bd, matrix, null, null, null, true);
            bitmap.bitmapData = bitmapData;
            //
            separate(bitmapData);
        }
        private function separate(bd:BitmapData):void {
            var r:BitmapData = new BitmapData(300, 300, false, 0xFF000000);
            var g:BitmapData = new BitmapData(300, 300, false, 0xFF000000);
            var b:BitmapData = new BitmapData(300, 300, false, 0xFF000000);
            r.copyChannel(bd, bd.rect, new Point(), BitmapDataChannel.RED, BitmapDataChannel.RED);
            g.copyChannel(bd, bd.rect, new Point(), BitmapDataChannel.GREEN, BitmapDataChannel.GREEN);
            b.copyChannel(bd, bd.rect, new Point(), BitmapDataChannel.BLUE, BitmapDataChannel.BLUE);
            //
            var rb:Bitmap = new Bitmap(r);
            var gb:Bitmap = new Bitmap(g);
            var bb:Bitmap = new Bitmap(b);
            rb.blendMode = BlendMode.SCREEN;
            gb.blendMode = BlendMode.SCREEN;
            bb.blendMode = BlendMode.SCREEN;
            //
            bb.x = 62;
            bb.y = 62;
            gb.x = 102;
            gb.y = 102;
            rb.x = 142;
            rb.y = 142;
            addChild(bb);
            addChild(gb);
            addChild(rb);
        }

    }

}