I have a basic question about manually removing event listeners in actionscript 3.
If I have a function like:
private function doStuff(event : Event):void
{
//let them save
var f:FileReference = new FileReference();
f.addEventListener(Event.COMPLETE,saveDone);
f.save(mp3Encoder.mp3Data,"output.mp3");
}
How do I remove the event listeners when the saveDone function is called? Normally I just change the “add” to “remove” like:
f.removeEventListener(Event.COMPLETE,saveDone);
However, f is a local variable, and I can’t get to it after the doStuff function ends.
private function saveDone(ev:Event){
f.removeEventListener(Event.COMPLETE,saveDone);
}
maybe try to reference the original object via the “target” property of the event? I haven’t tried it, but something akin to:
But I may be completely off.