PDA

View Full Version : Do I have to remove eventlisteners?


gronli21
05-24-2010, 09:53 AM
Hi,

On frame 1 I have a menu, with eventlisteres. When I click one of the menu-items it takes me e.g. to frame 2, where there are new listeners.

My question is do I have to remove the listeners on frame 1 when I am on frame 2? Are the listeners still active (and take up memory) - although I've removed the child(s)?

ActionScriptRetard
05-25-2010, 06:13 PM
e.g. to frame 2, where there are new listeners.

New listeners for the same menu? you don't need to add new eventlisteners if you have already added them..

gronli21
05-25-2010, 08:32 PM
No, it's new listeners for other items.

tadster
05-25-2010, 09:26 PM
if your not ever going back to frame one, then yes, you should remove the listeners.

Yes, the listeners do still take up memory.

Typical listener setup should be like this most of the time:


addEventListner(MouseEvent.CLICK, someFunc, false, 0, true);

//the true on the end tells it to be a weak listener
//and that lets it truly be garbage colleceted when it is no longer in use
//or removed



but there are times when listeners need to be strong, those times are few however.