# Problem removing EventListener

**URL:** https://forum.kirupa.com/t/problem-removing-eventlistener/313041
**Category:** flash
**Created:** [August 18, 2010, 3:10pm UTC](https://forum.kirupa.com/t/problem-removing-eventlistener/313041 "2010-08-18T15:10:47Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![yankleber](https://avatars.discourse-cdn.com/v4/letter/y/46a35a/32.png) [@yankleber](https://forum.kirupa.com/u/yankleber)
#### Post date: [August 18, 2010, 3:10pm UTC](https://forum.kirupa.com/t/problem-removing-eventlistener/313041/1 "2010-08-18T15:10:47Z")

</div>

Hi,

I am struggling with this. I have an EventListener function that receives a parameter. For any reason, seems that Flash doesn’t like it when it is time to REMOVE it:

```auto

var counter:Number = 0;

btnCreate.addEventListener(MouseEvent.CLICK,Create);
btnRemove.addEventListener(MouseEvent.CLICK,Remove);

function Create(e:MouseEvent):void
{
    addEventListener(Event.ENTER_FRAME,MyEvent(""));
}

function Remove(e:MouseEvent):void
{
        // the following line of code doesn't remove the Event!
    removeEventListener(Event.ENTER_FRAME,MyEvent(""));
}

function MyEvent(myparameter:String):Function
{
    return function (e:Event):void
    {
        counter++;
        trace (counter);
    }
} 

```

What is the trick to remove an EventListener when its triggered function does have a parameter?

Thanks!
