[Flex] 监听事件传递参数

监听在开发中使用的很多,但是addEventListener函数除了加事件类型和调用函数外,能不能加额外的参数呢?

 

其实是可以的,只要把所加的函数改为新定义的函数,在定义的函数中加入参数即可,示例:

private function handle(e:MouseEvent,str:String): void

{
       Alert.show(str);
}


private function methodWhereyouDostuffAndRegisterListener(): void

{
    var helloStr:String = "hello world!";
    ABCButton.addEventListener(MouseEvent.CLICK,function (e:MouseEvent):void {handle(e,helloStr);});
}

 

posted on 2009-03-27 17:15  Felix Fang  阅读(607)  评论(2编辑  收藏  举报

导航