Skip to main content
Inspiring
June 15, 2007
Question

batch preloading

  • June 15, 2007
  • 3 replies
  • 329 views
I would like to preload several thumbnails at once. What I mean by that
is that I would load for example 10 jpgs that each will by 20k, but the
preloader would show progress for all of them at 200k. Of course I would
like this to be dynamic, where flash will look and see how large the
jpgs are to determining how much to preload. Is this possible, or oven
good to do?

Thanks,
Brian
This topic has been closed for replies.

3 replies

Inspiring
June 16, 2007
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).
Inspiring
June 16, 2007
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.

Thank you!
Inspiring
June 16, 2007
For AS2:
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:
http://www.quip.net/blog/2007/flash/actionscript-20/tracking-multiple-files-part1
http://www.quip.net/blog/2007/flash/actionscript-20/tracking-multiple-files-part2