[AS2] Load external jpeg, setInterval, if exists

I want to create dynamic slideshows using external jpegs and for the slideshow to continue until all of the images have been shown. The images in the folder are named 0,1,2,3… etc

First of all I want a function to fire that loads an external jpeg.
It then checks to see if it exists.
If it does it waits 5 seconds then loads the next.
If it doesnt I want it to stop and show a default image.

So far I have


fileExists=new LoadVars();
fileExists.onLoad=checkIt;

function checkIt(success) {
	if(success) {
		mc_slideshow.loadMovie("0.jpg");	
	} else {
		mc_slideshow.loadMovie("default.jpg");
	}
}

fileExists.load("0.jpg");

This checks to see if the image exists and if it does it gets displayed. If it doesnt it shows the default image.

How can I add a counter to the “0.jpg” and the


fileExists.load

I Know it involves setInterval but I cant seem to get the two things working together!

Thanks for any help