6
votes

I am uploading a file to a server using a multipart URLLoader. I am able to upload the file fine. I have tried to listen to the progress event on the URLLoader but it only fires at the very end of the upload. How do I get the progress event more consistently through the upload?

1

1 Answers

2
votes

Have a progress-bar:

<mx:ProgressBar width="100%" id="progBar" mode="manual" />

Register a progress event handler:

refUploadFile.addEventListener(ProgressEvent.PROGRESS, onUploadProgress);

And handle it:

private function onUploadProgress(event:ProgressEvent):void {
        var numPerc:Number = Math.round(
            (Number(event.bytesLoaded) / Number(event.bytesTotal)) * 100);
        progBar.setProgress(numPerc, 100);
        progBar.label = numPerc + "%";
        progBar.validateNow();
}

If your files are small, it is normal to not receive many events. Try with bigger files.