您的位置:首页 > 其它

[Flex] 监听事件传递参数

2009-03-27 17:15 288 查看
监听在开发中使用的很多,但是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);});

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: