Preload next photo in slideshow?
I'm trying to help a friend with her Flash slideshow by getting it to preload the next photo (from a folder of numbered jpgs) when the current photo is done loading, but I can't quite get it worked out and I'm not sure what I'm missing... What I thought I might try is to have two movie clips to hold photos, one on the stage and one off the stage. I would load the current photo into the movie clip on the stage (pictures.slides) and when that finishes I would load the next photo in the movie clip off the stage (pictures.preloadNextPhoto) so that it would already download the image and would load faster when the user clicks "Next". It doesn't work. I won't load the whole script in here, but this is the movieloader function with the meat of the functionality:
function startLoading(Image) {
var MCL = new MovieClipLoader();
MCL.loadClip(Image, pictures.slides);
/* THIS IS THE BIT WHERE I TRY TO PRE-LOAD THE NEXT PHOTO */
var nextImageNum = (_level0.picture < _level0.totalPictures) ? _level0.picture + 1 : 1;
var nextImage = folder + nextSlideNumber() + nextImageNum + ".jpg"
MCL.loadClip(nextImage, pictures.preloadNextPhoto);
MCL.onLoadComplete = function() {
pictures.loader_txt.text = "";
};
MCL.onLoadProgress = function () {
var loadProgress = MCL.getProgress(pictures.slides);
loadedBytes = loadProgress.bytesLoaded;
totalBytes = loadProgress.bytesTotal;
percentage = Math.floor(loadedBytes/totalBytes*100);
pictures.loader_txt.text = percentage+"%";
};
MCL.onLoadError = function (){
pictures.loader_txt.text = "Picture not available";
};
}
Is there an easier way to do this? Any examples of how this might work better?
Thanks for the help!!
Eddie
