# removeEventListener() for an anonymous function

**URL:** <https://forum.kirupa.com/t/removeeventlistener-for-an-anonymous-function/250611>\
**Category:** flash\
**Created:** [January 31, 2008, 1:00am UTC](https://forum.kirupa.com/t/removeeventlistener-for-an-anonymous-function/250611 "2008-01-31T01:00:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![axiomflash](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/axiomflash/32/3952_2.png) [@axiomflash](https://forum.kirupa.com/u/axiomflash)\
**Post date:** [January 31, 2008, 1:00am UTC](https://forum.kirupa.com/t/removeeventlistener-for-an-anonymous-function/250611/1 "2008-01-31T01:00:10Z")

</div>

I have an event listener with an anonymous function literal, rather than a function reference. What I am trying to figure out is how to remove that event listener.

Obviously, I need a reference to the anonymous function, so the two functions are ===. But, something is going wrong… it just doesn’t work, ad this situation doesn’t generate any feedback to tell me what might be wrong.

There is some good info [here](http://blogs.adobe.com/simplicity/2007/10/post.html), but not a clear explanation.

```auto

private static var _myFunc:Function;

public static function addCreditsToolTip(clip:DisplayObject):void
{
    clip.addEventListener("rollOver",
    _myFunc = function():void
    {
        trace("yay!");
    });

    trace(_myFunc); //"function Function() {}" < PERFECT!
    clip.removeEventListener("rollOver", _myFunc); // < this doesn't work.
}

```
