Removing all event listeners in Flex

最后都变了- 提交于 2019-12-06 07:32:44

问题


How can I remove all event listeners on all components at once, especially when it is not known what listeners are attached to each component?


回答1:


You can override mx.core.FlexSprite, which UIComponent inherets from, and generate an array of listeners created. Doug Mc Cune put up source code here.

His blog says: removeAllEventListeners() – removes all event listeners of all types. This completely wipes out all event listeners for the component all at once.

Let us know if this does the job!




回答2:


No!

You might be able to mock something up with hasEventListener and willTrigger. But, there doesn't appear to be an obvious way to remove the event listeners without actually knowing the method name.

What do you want to do this for?




回答3:


There is an issue in Adobe JIRA for this task, please vote if you feel that it important for you

https://bugs.adobe.com/jira/browse/SDK-14127




回答4:


Elad Elrom has a post on his implementation to store event listener references, and be able to remove them all at once:

http://elromdesign.com/blog/2010/07/16/easy-way-to-store-event-listeners-reference-prevent-memory-leaks/



来源:https://stackoverflow.com/questions/3405808/removing-all-event-listeners-in-flex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!