Predictive Loading
Predictive loading is a method by which you determine the direction a user will take on your site and attempting to load that content into their cache before they get there. If this sounds suspiciously similar to the description of a preloader, it's because that's pretty much what it is. Unfortunately, somewhere along the line, the Flash community decided that a preloader suddenly meant "check out my cool loading bar". So to avoid being trapped into that categorical description, I'm sticking with the term predictive loader for the intent of clearer representation.
The predictive loader should be placed inside a shell swf. The shell swf should be something interesting enough to distract the user, while still being small enough for them to not have to stare at an initial loading bar. A 30k to 50k file is probably big enough. Once the shell swf is finished loading it's time to turn the predictive loader on. The loader works by pulling swfs out of a queue that can be set in an array or object, and loading them into a temporary container. After a swf has been loaded, it is pulled out of the queue and the process continues until the queue is empty.
When a user chooses a section to view, 2 conditions must be determined.
- Is the swf already in the users cache?
- Yes: load the swf into the main viewing window and leave the queue alone to load other files in.
- No: move to step 2
- Is the swf currently being loaded into the temporary container?
- Yes: display loading bar and when it's finished, load swf into the main viewing area.
- No: unload current swf from temporary container and push new swf to the front of the queue, display loading bar, load into main viewing area when finished.
After a requested swf has been loaded in, the queue will reset back to the previous item and continue the loading process.
Please note that setting up a predictive loader is not always the right method for loading data into your movie. If you have a picture gallery with 100+ images the user would probably appreciate not having all of those sitting in his/her cache in the offchance they might click on the thumbnail.
Example:
You can view an example of the predictive loader here. You can also view a version of the predictive loader implemented on the Mustard Lab main flash site. If your connection isn't too fast, you may be able to catch a glimpse of Igor cranking a loading wheel in between sections.
Additional Notes:
With a few minor tweaks you can set up the loading system to handle multidimensional arrays in order to manage seperate queues for different areas of the flash movie. That way if a user chooses a section, you can begin loading all the submovies inside that section to anticipate the content they'll want to view.
Download
Example Files: MLAB_flash_predictiveloader.zip
Size: 803 kb
Last Updated: 2003-04-16
