I've created a slideshow that loads the images through xml and it works great, except when an image is not loaded before it's supposed to be display.
The slideshow is pretty small, so I want to preload all images upfront before the slideshow starts, and this is where I'm having problems.
I can get one image to preload fine, but when trying to get them all to load, everything I try doesn't work how I would expect.
Doing a for statement seems to only load the last image, and a while loop breaks the script.
Here's an example of what I've tried:
Code:
for (i = 0; i < totalSlides; i++) {
preloadImg = preloadSlideNode.attributes.path;
trace(preloadImg);
mc.loadMovie(preloadImg);
preloadSlideNode = preloadSlideNode.nextSibling;
onEnterFrame = function() {
t = mc.getBytesTotal();
l = mc.getBytesLoaded();
trace(t);
if(t && l && t==l){
delete onEnterFrame
if (i == totalSlides) {
alphaTween = new mx.transitions.Tween(whiteOut, "_alpha",mx.transitions.easing.Regular.easeOut,0,100,_global.fadetime,true);
setInterval(gotoAndStop(2),_global.fadetime);
}
}
}
}
Basically this would work if I could get it to wait until each image is loaded before starting the loop again.
Anyone have any suggestions?