# How do I call RemoveEventListener()?

**URL:** https://forum.kirupa.com/t/how-do-i-call-removeeventlistener/238241
**Category:** flash
**Created:** [September 8, 2007, 8:50pm UTC](https://forum.kirupa.com/t/how-do-i-call-removeeventlistener/238241 "2007-09-08T20:50:41Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Aesir](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@Aesir](https://forum.kirupa.com/u/Aesir)
#### Post date: [September 8, 2007, 8:50pm UTC](https://forum.kirupa.com/t/how-do-i-call-removeeventlistener/238241/1 "2007-09-08T20:50:41Z")

</div>

I have a firework class, which fades over time and finally removes itself from the display parent.

```auto

package {
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.EventDispatcher;
 
public class Firework_mc extends MovieClip {
private var lifetime:int; // lifetime, measured in age events
 
public function Firework_mc( r:Number, lifetime:int ){
width = r * 2;
height = r * 2;
this.lifetime = lifetime;
addEventListener( Event.ENTER_FRAME, fade );
}
 
private function fade( event:Event ):void {
alpha -= 1 / lifetime;
if ( alpha <= 0 ){
parent.removeChild( this );
}
}
}
} 

```

However, the EnterFrame event listener stays around, so after a Firework\_mc removes itself from the display, I get the following error:  
_TypeError: Error #1009: Cannot access a property or method of a null object reference._  
_at Firework\_mc/::fade()_

What is the syntax for removing the EnterFrame listener? I have looked around and attempted to use EventDispatcher.removeEventListener( Event.ENTER\_FRAME, this ); but it gives me the following error:  
_1061: Call to a possibly undefined method removeEventListener through a reference with static type Class._

Thanks in advance.
