I want to dispatch a custom event when the two files are downloaded or uploaded successfully. I use
fileRef.addEventListener(Event.COMPLETE, completeHandler);
fileBigRef.addEventListener(Event.COMPLETE, completeHandler);
to listen the complete event with only 1 handler.
function completeHandler(event:Event):void{
var e:Event=new Event("addInfoDone");
dispatchEvent(e);
fileBigRef.removeEventListener(Event.COMPLETE,completeHandler);
fileRef.removeEventListener(Event.COMPLETE,completeHandler);
}
I want the event to be dispatched only once when both of the fileRef and fileBigRef are complete transfered. Any ideas?? My brain is fry now and can’t think of anything….. Thanks for the help.
For a quick and dirty solution, how about defining a counter that increments each time
completeHandleris fired. Once the counter reaches the number of files you’re expecting (sounds like you’re expecting 2), you fire youraddInfoDoneevent: