ActionScript3.0でイベントハンドラに引数を渡す

Twitter ツイート Hatena Bookmark ブックマーク

ActionScript使っているとイベントハンドラに引数を渡したいっていうことが多々あると思います。
なんだかいろいろな言語触っていると忘れてしまうので、メモしておきます。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
public function hoge(userid:int):void
		{
			testBtn.addEventListener(MouseEvent.CLICK,hogeHandler(userid));
		}

		public function hogeHandler(userId:int):Function
		{
			return function(event:MouseEvent):void
			{
				Alert.show(String(userid));
			}
		}

参考
イベントハンドラに引数を渡す

comments powered by Disqus
Built with Hugo
テーマ StackJimmy によって設計されています。