this is a part of my code which i use for downloading files.
this works fine when i download one file at a time.
the problem is when i start downloading another file while previous is still downloading, my proloader freaks out and start showing both download percentages at once.
how could i write a preloader to add multiple values together?
public function download( url:String, fileName:String = null ):void {
_URLRequest = new URLRequest(url);
addListeners();
try {
_fileRef.download(_URLRequest, fileName);
} catch (er:Error) {
trace(er.message);
}
}
private function addListeners():void {
_fileRef.addEventListener(Event.CANCEL, cancelHandler, false, 0, true);
_fileRef.addEventListener(Event.COMPLETE, completeHandler, false, 0, true);
_fileRef.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler, false, 0, true);
_fileRef.addEventListener(ProgressEvent.PROGRESS, progressHandler, false, 0, true);
_fileRef.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler, false, 0, true);
_fileRef.addEventListener(Event.SELECT, selectHandler, false, 0, true);
}
private function progressHandler(e:ProgressEvent):void {
_percent = e.bytesLoaded / e.bytesTotal;
_loaded = _percent;
_txt.text = _loaded + "%";
}
i can post more code if neccessary.