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: クロージャを使ってaddEventListenerしたイベントをremoveEventListenerする。

http://level0.kayac.com/2009/09/event_closure.php
* 
* arguments.calleeについては下記のドキュメントをご覧ください。
* http://help.adobe.com/ja_JP/AS3LCR/Flash_10.0/arguments.html
/**
 * Copyright ton ( http://wonderfl.net/user/ton )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/aKxO
 */

/**
 * http://level0.kayac.com/2009/09/event_closure.php
 * 
 * arguments.calleeについては下記のドキュメントをご覧ください。
 * http://help.adobe.com/ja_JP/AS3LCR/Flash_10.0/arguments.html
 */
package {
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.text.TextField;

	public class Test extends Sprite {
		
		public function Test() {
			var t:TextField = new TextField();
			t.autoSize = "left";
			t.width = 400;
			t.height = 600;
			addChild(t);
			
			var count:int = 0;
			var max_count:int = 30;
			
			stage.addEventListener(Event.ENTER_FRAME, function(e:Event):void {
				count++;
				if (count >= max_count) {
					e.target.removeEventListener(e.type, arguments.callee);
				}
				
				t.appendText(count+"\twillTrigger : " + willTrigger(e.type) + "\n");
			});
		}
		
		
		
	}
}