开发者

Flex Multipart Upload Progress

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜