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, but not a clear explanation.
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.
}