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

forked from: ローディングを使う

/**
 * Copyright jack ( http://wonderfl.net/user/jack )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/nMQ4
 */

// forked from HaraMakoto's ローディングを使う
// forked from HaraMakoto's forked from: flash on 2009-11-17
// forked from HaraMakoto's flash on 2009-11-17
package {
    import flash.display.Sprite;
    import flash.display.Loader;
    import net.wonderfl.utils.WonderflSWFUrl;
    import flash.net.URLRequest;
    import flash.events.Event;
    import flash.system.Security;
    import flash.events.MouseEvent;
    import jp.progression.commands.Func;
    import jp.progression.commands.lists.SerialList;


    [SWF(backgroundColor="0xFFFFFF", width="465", height="465", frameRate="60")]
    public class FlashTest extends Sprite {
        
        private var loader:Loader = new Loader();
        private var loadView:Object;
        
        public function FlashTest() {
            Security.loadPolicyFile("http://swimmingbird.heteml.jp/crossdomain.xml");
            addChild(loader);
            
            loadLoadingView(photoLoadStart);
        }
        
        private function photoLoadStart():void {
            loadView.loadStart();
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, photoCompleteHandler);
            loader.load(new URLRequest("http://www.blf-g.com/test/blf.png"));
            addEventListener(Event.ENTER_FRAME, enterFrameHandler);
        }
        private function enterFrameHandler(event:Event):void {
            loadView.attachLoadValue(loader.contentLoaderInfo.bytesLoaded / loader.contentLoaderInfo.bytesTotal);
        }
        
        
        private function photoCompleteHandler(event:Event):void {
            removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
            loadView.loadComplete();
        }
        
//--------------------------------------------------------------------------------//
// ローディング表示呼び出し
//--------------------------------------------------------------------------------//       
        private function loadLoadingView(_f:Function):void {
            var CODE_PAGE:String = "http://wonderfl.net/code/fec7bdea47c77f160e52cd2c448bb49bb209ea92";
            var path:String = WonderflSWFUrl.getURLFromPageURL(CODE_PAGE);
            var ldr:Loader = new Loader();
            addChild(ldr);
            var s:SerialList = new SerialList();
	    s.addCommand(
		new Func(ldr.load, [new URLRequest(path) ],ldr.contentLoaderInfo, Event.COMPLETE),
                function():void{loadView = ldr.contentLoaderInfo.content; },
                new Func(_f)
	    );
            s.execute();
            
        }
    }
}