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

Bitmap loader test

Get Adobe Flash player
by Loth2012 18 Oct 2012
    Embed
/**
 * Copyright Loth2012 ( http://wonderfl.net/user/Loth2012 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/ouXa
 */

package {
    import flash.events.Event;
    import flash.display.Sprite;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.system.Security;
    public class RandomLand extends Sprite {
        private static var PATH:String = "http://assets.wonderfl.net/images/related_images/";
        private static var FILES:Array = [
        '/d/d7/d795/d7959b94154d0ea31db77a96c032f1e6f007ba76',//fork
        '/9/9e/9ec2/9ec2e9ecdb820c57bb1611a40a8027c2e3f25e03'//logo
        ];
        private var photo1:PhotoLoader;
        private var _i:int;
        private var images:Vector.<BitmapData>;
        public function RandomLand() {
            images = new Vector.<BitmapData>();
            photo1 = new PhotoLoader();
            photo1.addEventListener(PhotoLoader.COMPLETE, setup1, false, 0, true);
            photo1.load(PATH+FILES[0]);
        }
        private function setup1(e:Event):void {
            var b:Bitmap = new Bitmap(photo1.content);
            addChild(b);
            b.x = (stage.stageWidth>>1) - (128);
            b.y = (stage.stageHeight>>1) - (128);
        }
    }
}


//-------------------------------------------LOADING IMAGES
import flash.display.Sprite;
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.net.URLRequest;
import flash.events.Event;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.system.LoaderContext;

class PhotoLoader extends Sprite {
    private var loader:Loader;
    private var info:LoaderInfo;
    public var content:BitmapData;
    public static const INIT:String = Event.INIT;
    public static const COMPLETE:String = Event.COMPLETE;

    public function PhotoLoader() {
        loader = new Loader();
        info = loader.contentLoaderInfo;
    }
    public function load(file:String):void {
        info.addEventListener(Event.INIT, initialize, false, 0, true);
        info.addEventListener(Event.COMPLETE, complete, false, 0, true);
        loader.load(new URLRequest(file), new LoaderContext(true));
    }
    private function initialize(evt:Event):void {
        content = Bitmap(info.content).bitmapData;
       // content = (info.content) as bitmapData;
        dispatchEvent(new Event(PhotoLoader.INIT));
    }
    private function complete(evt:Event):void {
        info.removeEventListener(Event.INIT, initialize);
        info.removeEventListener(Event.COMPLETE, complete);
        dispatchEvent(new Event(PhotoLoader.COMPLETE));
        loader.unload();
        loader = null;
    }

}