I have a series of buttons. When a button is clicked a component (instructorView) is loaded into a container named passageContainer:
Each time I load a new component, I remove the old component first:
The component includes an eventListener which is triggered when a key is pressed.
The first time I load a component and press a key the event is triggered once.
The second time the event is triggered twice.
The third time the event is triggered three times, and so on.
I'm almost certain that the eventListeners are not being removed although the components are removed. So the event listeners execute multiple times.
Is it possible for the eventListeners to remain after the components have been removed? If so, how can I remove them?
It means the components are still in the memory, they are tightly coupled, you need to do makesure that the event listeners are loosely coupled/weakreferenced.
(OR) you have to remove the listeners manually, by doing this.removeEventLIstener(...... on each and every component to all the events that are registered in the component before you remove it from the memory.
Message was edited by: saisri2k2