# Removing an EventListener and this

**URL:** https://forum.kirupa.com/t/removing-an-eventlistener-and-this/295524
**Category:** Uncategorized
**Created:** [August 31, 2009, 9:22pm UTC](https://forum.kirupa.com/t/removing-an-eventlistener-and-this/295524 "2009-08-31T21:22:00Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![rokosz](https://avatars.discourse-cdn.com/v4/letter/r/b5e925/32.png) [@rokosz](https://forum.kirupa.com/u/rokosz)
#### Post date: [August 31, 2009, 9:22pm UTC](https://forum.kirupa.com/t/removing-an-eventlistener-and-this/295524/1 "2009-08-31T21:22:00Z")

</div>

This seems like its pretty obvious, add remove, what can go wrong?

Well, mine isn’t removing – not sure why but get the feeling its because the handler was added outside of any function (stage/root). And inside the function I need to ref the stage? But what is the proper label for the stage? “stage.” and “root1” didn’t work for me. or is it something else completely?

```auto
this.addEventListener(MouseEvent.ROLL_OVER,RollitOver);
this.addEventListener(MouseEvent.ROLL_OUT,RollitBack);
this.addEventListener(MouseEvent.CLICK,ClickIt);
 
function RollitOver(event:MouseEvent) {
trace("Rolled on in");
}
function RollitBack(event:MouseEvent) {
trace("Rolled on out");
}
function ClickIt(event:MouseEvent) {
// trace(hasEventListener(MouseEvent.ROLL_OUT)); // shows true
trace("clicked it");
// this.removeEventListener(MouseEvent.ROLL_OUT,RollitBack,true); // tried false/default capture too
removeEventListener(MouseEvent.ROLL_OUT,RollitBack,true); 
// what happens is the trace "Clicked it" appears and then when the mouse rolls out 
// the trace "rolled on out" also appears, but that should be removed. (or, at least, that's
// the desire.)
}

```

You might see extra spaces in the text/post above. they’re artifacts of a strange Kirupa edit session.

thanks good people, Bryan
