# fileReference multiple download and preloader

**URL:** <https://forum.kirupa.com/t/filereference-multiple-download-and-preloader/306076>\
**Category:** flash\
**Created:** [March 9, 2010, 8:58am UTC](https://forum.kirupa.com/t/filereference-multiple-download-and-preloader/306076 "2010-03-09T08:58:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![werehunt](https://avatars.discourse-cdn.com/v4/letter/w/b782af/32.png) [@werehunt](https://forum.kirupa.com/u/werehunt)\
**Post date:** [March 9, 2010, 8:58am UTC](https://forum.kirupa.com/t/filereference-multiple-download-and-preloader/306076/1 "2010-03-09T08:58:54Z")

</div>

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?

```auto
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.
