# Removing listeners doesn't seem to work

**URL:** <https://forum.kirupa.com/t/removing-listeners-doesnt-seem-to-work/175652>\
**Category:** Uncategorized\
**Created:** [January 16, 2006, 8:07pm UTC](https://forum.kirupa.com/t/removing-listeners-doesnt-seem-to-work/175652 "2006-01-16T20:07:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![voxecho](https://avatars.discourse-cdn.com/v4/letter/v/278dde/32.png) [@voxecho](https://forum.kirupa.com/u/voxecho)\
**Post date:** [January 16, 2006, 8:07pm UTC](https://forum.kirupa.com/t/removing-listeners-doesnt-seem-to-work/175652/1 "2006-01-16T20:07:51Z")

</div>

hi all,

I have a mouse and stage listener that watches for stage.onResize and Mouse.onMouseDown

they work just fine, however i can’t seem to remove them when i don’t want to use them, they are triggering even though i’ve tried to remove them. Any thoughts on what is wrong with the following code?

```auto
 private function setEnvironmentListeners(kill){
  if(kill){
   Stage.removeListener($objStage);
   delete $objStage;
   $objStage = undefined;
 
   Mouse.removeListener($objMouse);
 
   delete $objMouse;
   $objMouse = undefined;
  } else {
   /*
   * Watch for mouse clicks, we will check to see if the user has clicked outside the movieclip,
   * if so, then we want the menu to close.
   */
   $objMouse = new Object()
   $objMouse._name = "listener";
   $objMouse._parent = this;
   $objMouse.onMouseDown = function(){_parent.dispatchGenEvent({type:"__onMouseDown",_typeof:"MOUSE"});}
   Mouse.addListener($objMouse);
 
   /*
   * watch for resizing of the stage
   */
   $objStage = new Object();
   $objStage._name = "listener";
   $objStage._parent = this;
   $objStage.onResize = function(){_parent.dispatchGenEvent({type:"__onResize",_typeof:"STAGE"});}
   Stage.addListener($objStage);
  }
  // display the listeners to see if they are still there.
  trace($objMouse);
  trace($objStage);
 }

```
