How to remove all event listeners from a display object?

后端 未结 5 987
天涯浪人
天涯浪人 2021-02-08 15:21

Is there a way to determine which event listeners are registered with a display object? I want to remove all event listeners from a display object so that I can assign new ones

5条回答
  •  不要未来只要你来
    2021-02-08 16:11

    This is sort of a hack, but in some (perhaps most cases), you can easily set the display object to null and re-initialize it and then re-configure it with zero visual disruption.

    This has the added bonus of removing all event listeners.

    Unless you are doing this in an app that already has hundreds of listeners and objects then it should work perfectly fine so long as you can tolerate reconfiguring your display object.

    Obviously, you shouldn't do this on anything that is doing something crazy in the constructor like loading data.

提交回复
热议问题