forked from: flash on 2010-1-26

by qq49121294 forked from flash on 2010-1-26 (diff: 8)
PreLoader 作成用サンプルコード
♥0 | Line 35 | Modified 2012-08-20 12:31:40 | MIT License
play

ActionScript3 source code

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

// forked from tan_go238's flash on 2010-1-26
package {
    import flash.events.Event;
    import flash.events.TimerEvent;
    import flash.utils.Timer;
    import flash.text.TextField;
    import flash.display.Sprite;
    
    /**
     * PreLoader 作成用サンプルコード
     */
    public class FlashTest extends Sprite {
        
          private var tf:TextField;
        private const START_X:int = 0;
        private const DELAY:int = 30;
        private const REPEAT:int = 0;
        private const _WIDTH:int = 150;
        
           private var timer:Timer;
          private var _loaded:Number = 0;
          private var _totalBytes:Number = 98765;
                        
        public function FlashTest() {
             tf=new TextField();
             addChild(tf);
             tf.y=20;
             this.addEventListener(Event.ENTER_FRAME,enter_frame);
        }
        
        private function enter_frame(e:Event):void {
                update();
        }
        
        private function update():void {
                graphics.beginFill(0xCC9933);
                graphics.drawRect(START_X, 10, _loaded/_totalBytes * _WIDTH, 10);
                graphics.endFill();
                tf.text="loaded"+int(_loaded/_totalBytes*100)+"%";
                if(_loaded <= _totalBytes){
                    _loaded += 300;
                }
        }
    }
}