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

Timer(1000)はどう呼ばれるのか

1000のタイマーをひたすら観測するテスト
Get Adobe Flash player
by keno42 18 Jun 2009
    Embed
/**
 * Copyright keno42 ( http://wonderfl.net/user/keno42 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/eDGF
 */

package 
{
	import flash.display.Sprite;
	import flash.events.TimerEvent;
	import flash.text.TextField;
	import flash.utils.getTimer;
	import flash.utils.Timer;
	
	/**
	 * 1000のタイマーをひたすら観測するテスト
	 */
	public class TimerTest extends Sprite
	{
		private var t:Timer = new Timer(1000);
		private var tf:TextField = new TextField();
		
		private var first:String = "";
		public function TimerTest () 
		{
			this.addChild( tf );
			t.addEventListener(TimerEvent.TIMER, onTimer);
			t.start();
		}
		private function onTimer(e:TimerEvent):void {
			if ( first == "" ) {
				first = String(getTimer());
			}
			
			tf.text = "first: " + first + "\n" + "current: " + getTimer();
		}
		
	}
	
}