I have an array of FileReference objects which have several listeners attached to each of them, should I be removing each listener in it's handler method, or should I remove them all in the complete handler?
I read somewhere to use weak references for listeners, but I would think it would be better to explicitly remove listeners (yes?/no?)
for each(var f:Object in fileCollection){
var myFile:FileReference = f.file;
myFile.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, onUploadCompleteData)
myFile.addEventListener(ProgressEvent.PROGRESS, onProgress);
myFile.addEventListener(IOErrorEvent.IO_ERROR, onError);
myFile.addEventListener(Event.COMPLETE, onComplete);
}
private function onUploadCompleteData(e:DataEvent):void{
// doin my thing here
removeListeners(e)
}
private function removeListeners(e:Event):void{
var myFile:FileReference = FileReference(e.target)
myFile.removeEventListener(DataEvent.UPLOAD_COMPLETE_DATA, onUploadCompleteData)
myFile.removeEventListener(ProgressEvent.PROGRESS, onProgress);
myFile.removeEventListener(IOErrorEvent.IO_ERROR, onError);
myFile.removeEventListener(Event.COMPLETE, onComplete);
}