1 Reply Latest reply on Jan 13, 2011 2:12 PM by saisri2k2

    How to remove an event listener

    SiHoop Level 1

      I have a series of buttons. When a button is clicked a component (instructorView) is loaded into a container named passageContainer:

      passageContainer.addChild(instructorView);

       

      Each time I load a new component, I remove the old component first:

      passageContainer.removeAllChildren();

       

      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?

       

      Thanks!