flash on 2010-1-26

by tan_go238
PreLoader 作成用サンプルコード
♥0 | Line 32 | Modified 2010-01-26 11:53:14 | MIT License
play

ActionScript3 source code

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

package {
	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() {
			timer = new Timer(DELAY, REPEAT);
			timer.start();
			timer.addEventListener(TimerEvent.TIMER, timerHandler);
        }
        
        private function timerHandler(e:TimerEvent):void {
        		update();
        }
        
        private function update():void {
        		graphics.beginFill(0xCC9933);
        		graphics.drawRect(START_X, 10, _loaded/_totalBytes * _WIDTH, 10);
        		graphics.endFill();
        		if(_loaded <= _totalBytes){
	        		_loaded += 300;
        		}
        }
    }
}

Forked