This content has been marked as final. Show 3 replies
Its not - as I understand it - possible to do this accurately without letting flash know the total bytesizes before hand. Flash can't check the size before downloading. And even as it starts, the information is not correct until the first onLoadProgress event for each MovieClipLoader. There are two ways to overcome this if you have a 'MultiLoader' style class which either queues or attempts multiple simultaneous downloads.
1. To accurately reflect the progress, store the information about the jpgs in an external xml file. So the xml would have the image names, their urls and their total byte size as well. With this data ahead of the loading process its then possible to create the type of accurate feedback of progress that you want. The data you get from a MovieClipLoader is incorrect in the early stages of a load. This definitely applies to getBytesTotal - I can't remember if getBytesLoaded is incorrect data as well before the first onLoadProgress event. So if you do it this way (and the data about the images in the xml is correct) you should just maintain an array of BytesLoaded data which is updated at the correct index for each loading clip from your onLoadProgress events. And you can dispatch a groupProgress event which would give the sum of the elements in the array as the groupBytesLoaded.
2. Another option is to check the validity of each clip's data first before reporting it as part of the total. You only report the group's progress in terms of a) valid bytesLoaded b) valid bytesTotal c)number of 'valid' clips as a percent of total number of clips. In this case a/b * c is an approximation of the group progress. I works OK if the images are all going to be around the same byte size, but it is only an 'approximation' attributing an equal proportion of the total group progress to each image.
I very recently built a class that queues image loading using the second approach above, inspired by some work David Stiller had done on a MultiLoader class and the associated comments in his blog, but using a different approach for validating individual clip data and handling of individual MovieClipLoader listeners. You might want to read it - David outlines some of the issues in more detail with examples here:
GWD, thank you very much. This is exactly the kind of information I was
looking for. The links were not working, but I will google this topic,
now that it seems I have more acurate termonology for what it is I am
trying to do.
You're welcome. Good luck. The links work fine on the Adobe website forum ... but you're using a newsreader perhaps. Just put "as2 multiloader" in google without the quotes and you'll get there. I think that's how I found it originally.
If I ever get to the point where I'm half proud of my approach to doing it I'll post it online somewhere too ... but its not finished yet (it works .. there's just some more features I want to add).