# Preloading images - Automated slideshow

**URL:** <https://forum.kirupa.com/t/preloading-images-automated-slideshow/244902>\
**Category:** flash\
**Created:** [November 23, 2007, 9:41am UTC](https://forum.kirupa.com/t/preloading-images-automated-slideshow/244902 "2007-11-23T09:41:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![James001](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@James001](https://forum.kirupa.com/u/James001)\
**Post date:** [November 23, 2007, 9:41am UTC](https://forum.kirupa.com/t/preloading-images-automated-slideshow/244902/1 "2007-11-23T09:41:30Z")

</div>

Hi, can anyone help me here. I’ve created a slideshow that runs off a setInterval. Basically I just want the next jpg in the array to load whilst the current slide is on the screen for the specified interval.

///I also tried using this piece of code:  
\_root.slideTween\_mc.t1\_mc.loadMovie (pathToPics + counter + “.jpg” || + “.swf”, 20);  
//not sure why this doesn’t work. Any ideas?

//Here’s the code  
///////////////////////  
\<code\>  
\_global.counter = 1;  
\_global.pathToPics = “HTemplates/”;  
//AUTOMATED SLIDESSHOW//PT1  
automated\_btn.toggled = true;  
automated\_btn.onRelease = function(){  
if (this.toggled) {  
trace(toggleActive)  
timer = setInterval(auto, 2500);  
} else {  
trace(untoggled)  
clearInterval(timer);  
}  
}  
//AUTOMATED SLIDESSHOW PT2  
function auto(){  
this.toggled = false;  
if (this.toggled) {  
\_root.slideTween\_mc.gotoAndPlay(“next”);  
} else {  
\_root.slideTween\_mc.gotoAndPlay(“nexit”);  
//  
if (counter \< 20) {  
counter ++;  
} else {  
counter -= 19;  
}  
}  
}  
//Next pic //It would be recommended to use a preloader before the animation can run!!  
function changePic(){  
\_root.slideTween\_mc.t1\_mc.loadMovie (pathToPics + counter + “.jpg” || + “.swf”, 20);  
//indicate the number of the slide  
screenCounter\_txt.text = counter;  
}  
\</code\>
