0
votes

If in a component I have basic Button which can propagate MouseEvent.CLICK like this :

<s:Button id="btn" click="someFunction(event)" />

Should I manually remove this event if I remove my component with parent.removeElement(myButton) function or is it automatically removed ?

Thanks for clarification

1
Of course it will automatically removed. no need to remove manually. - ketan
Ok thanks. Is this the same if I listen event with addEventListener() function ? Or shold I use weak reference ? - Olivier J.
same as addEventListener() - ketan
Thanks again ! I saw that if I use Timer, I have to use removeEventListener to avoid memory leaks, is it true ? - Olivier J.
Once you set timer = null it should be ready for garbage collection. In smaller projects in most cases it makes no diferenece. In bigger ones it porpably will make difference. But, Personally, In my code, I would still remove the listener. - ketan

1 Answers

1
votes

Of course it will automatically removed event once you remove component(Button). There is no need to remove event manually then.

For Timer:

Once you set timer = null it should be ready for garbage collection. In smaller projects in most cases it makes no difference. In bigger one it probably will make difference. But, Personally, In my code, I would still remove the listener.