ActionScript3.0でイベントハンドラに引数を渡す
ActionScript使っているとイベントハンドラに引数を渡したいっていうことが多々あると思います。
なんだかいろいろな言語触っていると忘れてしまうので、メモしておきます。
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));
}
}