View Full Version : ProgressBar for multiple files uploading?
lwang
05-20-2008, 03:57 PM
I have a AS code that will read a number of XML files and process some of the data at the initiation process. Is there a way to use a ProgressBar to indicate the progress of this whole process?
razvanpat
05-20-2008, 04:46 PM
Yes you can. Create a queue of the processed files and update a progress bar by using the sum of bytes loaded for all files / total bytes of all the files. When I have to implement functionality similar to this I usually create a class that will manage the loading. Each file should have a complete flag that is false when the operation starts. Whenever a file is complete set its flag on true and check all the other flags. If all the flags are true then you dispatch a complete event or call a function that should be executed once all files are loaded.
lwang
05-21-2008, 01:14 PM
razvanpat, thanks for the reply. The solution makes sense to me, but could you be a bit more specific in terms of what mode to use, how to update the progress bar using the sum of bytes loaded? Thanks again.
razvanpat
05-22-2008, 09:36 PM
I am sure there are better ways to do this but here is a solution that is fairly simple to implement: every time an object in your load queue receives a progress event you call a function that goes trough all the objects in the queue and calculates two sums, one for the total bytes and one for the loaded bytes, then you pass those parameters to another function/class that handles the drawing of the progress bar.
lucidmedia
05-23-2008, 01:51 AM
Give Arther Debert's awesome bulkloader class a close look
http://code.google.com/p/bulk-loader/
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.