监听在开发中使用的很多,但是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);});
}

 

相关文章:

  • 2021-07-03
  • 2021-06-17
  • 2021-08-27
  • 2022-12-23
  • 2022-02-28
  • 2022-02-21
  • 2022-12-23
猜你喜欢
  • 2022-01-01
  • 2021-08-05
  • 2021-07-19
  • 2022-12-23
  • 2022-01-09
  • 2022-12-23
  • 2021-12-09
相关资源
相似解决方案