views:

656

answers:

3

I need to create an application where I can add files for upload. As I add items for upload, a progressbar should be displayed along with each item added. And when I click for file upload, the progress of file upload for each file should be reflected in the progress bar. The progress should use the function like

.....
addEventListener(ProgressEvent.Progress, uploadProgressHandler);

private function uploadProgressHandler(event:ProgressEvent):void
{
    var numPerc:Number = Math.round((Number(event.bytesLoaded) / Number(event.bytesTotal)) * 100);

    //this.progBar.validateNow();

    .....
}  

Can anyone provide help me out?

A: 

Flex has a ProgressBar class, have you checked that out yet?

Amarghosh
Yah I used the same. My requirement is to display progressbar for each item added to the upload list, a progressbar is added and to show progress in each progressbar.
Roshan
A: 

Here are two great examples of Flex file uploaders (using HTTP):

alt text

In order to make the above two examples work together to achieve the desired result (multiple file uploader, one ProgressBar per preloader, in Flex), all you need to do is:

  1. Download the Flex File Uploader PHP Project
  2. Download the Merb AIR Uploader and copy/paste the "UploadProgressComponent.mxml" somewhere into the PHP project (copy to src/UploadProgressComponent.mxml for now).
  3. Replace the DataGrid with a List and a Custom ItemRenderer in FileUpload.mxml in the Flex File Uploader PHP Project.

Replace this:

<mx:DataGrid id="listFiles" left="0" top="0" bottom="0" right="0"  
 allowMultipleSelection="true" verticalScrollPolicy="on"
 draggableColumns="false" resizableColumns="false" sortableColumns="false">
    <mx:columns>
        <mx:DataGridColumn headerText="File" dataField="name" wordWrap="true"/>
        <mx:DataGridColumn headerText="Size" dataField="size" width="75" textAlign="right"/>
    </mx:columns>
</mx:DataGrid>  

with this:

<mx:List id="listFiles" left="0" top="0" bottom="0" right="0"
 allowMultipleSelection="true" verticalScrollPolicy="on"
 itemRenderer="UploadProgressComponent"/>  

The result: Multiple file uploader in Flex, with a custom ItemRenderer that has a ProgressBar for each FileReference. Uploads to a PHP script, which you can swap out for anything.

Should be very easy to customize from there. Let me know if that works, Lance

viatropos
I have gone through it but my requirement is quite different from this. I need a progressbar for each file added to the list and the progress is shown in the corresponding progressbar for each file upload whereas in the link you provided me with, the progress is shown in the same progressbar.
Roshan
the updated linked example shows how to create a progressbar for each file, that should do it!
viatropos
Thanks for your support. But, I am using Flex 2 actionscript and I get an error because of WindowedApplication in script "App.as". So , still my problem is not solved.
Roshan
try the above solution. you may run into errors because I haven't built the entire thing, but it's working on my end! try to give that a shot, debug as needed, and let me know if it solved your problem (or got you on the right track which, even better). cheers
viatropos
Thanks for your help. But the first solution i.e. the link "http://weblog.cahlan.com/files/FileUpload/FileUploadApp.html" gave a hint to achieve my task of creating an application for uploading files with progressbar. Cheers.
Roshan
A: 

See these examples:

Multiple File Upload with Flex and PHP
which looks like this:

image1

Multiple File Upload With Progress Bar Using Flash and ASP.NET
which looks like this:

image2

harrymc