A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: How can I remove eventlistener from the stage?

  1. #1
    Senior Member
    Join Date
    Oct 2002
    Posts
    126

    How can I remove eventlistener from the stage?

    Hi,

    I have a main swf file which loads another swf file.
    From the loaded swf file I add a keyboard event listener to the stage.

    When I remove the loaded SWF from the main file the keyboard event listener is still active on the stage.

    How can I remove the event listener from the stage within the main swf file?

    Thank you.

  2. #2
    Senior Member
    Join Date
    Oct 2002
    Posts
    126
    I think this is probably the only way.
    Remove all listeners and timers when the swf file is removed from the stage.

    addEventListener(Event.REMOVED_FROM_STAGE, onRemove);

    function onRemove(e:Event):void
    {
    stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
    stage.removeEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
    clearInterval(nInterval);
    }

    so clean your own mess

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center