Clear Event Listener for the Displayobject in Actionscript
Does removeChild clear the associated event开发者_运维百科 listener related to those childs?
Not by default -- the final parameter of addEventListener is useWeakReferences:Boolean = false
. If that is set to true, the listener should clean up when the object leaves the stage. It does not always work as cleanly as that though.
It is best, if possible, to remove all listeners manually before removing an object from the stage. That way you can probably get garbage collection to take it. If you miss it or forget, then it is possible that Flash will forgive you, but it is also possible that it will initiate a blood feud which makes the Hatfields and McCoy's blush (Well, it can at least cause a headache).
精彩评论