flash on 2009-12-8

by zahir
♥0 | Line 30 | Modified 2009-12-08 21:42:06 | MIT License
play

ActionScript3 source code

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

package{
	import flash.display.Graphics;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.utils.getTimer;

	public class B3 extends Sprite{
		private var t:TextField;
		
		private const loop:Number = 100000;
		
		public function B3(){
			t = new TextField();
			t.width = t.height = 465;
			addChild(t);
			
			var s:Shape = new Shape();
			var g:Graphics = s.graphics;
			
			$("Rect", function():void{
				g.clear();
				g.beginFill( 0 );
				g.drawRect( 0,0, 30,30);
				g.endFill();
			});
		}
		
		private function $(txt:String, func:Function):void{
			var time:int = flash.utils.getTimer();
			for(var i:int = 0; i<loop; i++) func();
			time = getTimer() - time;
			
			t.appendText( txt + "  ::  " + time + " ms\n");
		}
	}
}