[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);});
}

原文地址:https://www.cnblogs.com/felixfang/p/1423357.html