etard
09-30-2003, 03:35 PM
I need to try to find a nice small scrpipt that allows me to load images in order on a page. I am using the following script, but I am open to something else:
var imgArray = new Array("a1","a2","a3","a4","a5","a6","a7","a8","a9","a10");
var len = imgArray.length
var imgDir = "";
var num = 0;
for (i = 0; i < len; i++) {
imageObj1 = imgArray[i] + "";
temp = eval(imageObj1 + " = new Image()");
temp.src = imgDir + imageObj1 + ".jpg";
}
function StartCycle() {
eval("document."+imgArray[num]+".src = "+imgArray[num]+".src");
num = num + 1;
if (num < len) {
setTimeout("StartCycle()", 1000);
}
}
but the problem is that when the page loads, the images load as thye would on any site (at random so to speak), and rather than load the images 1 by 1 in my order, it loads them then removes them 1 by 1. Why is that happening? It is like it is working, but in reverse. What am I missing?
var imgArray = new Array("a1","a2","a3","a4","a5","a6","a7","a8","a9","a10");
var len = imgArray.length
var imgDir = "";
var num = 0;
for (i = 0; i < len; i++) {
imageObj1 = imgArray[i] + "";
temp = eval(imageObj1 + " = new Image()");
temp.src = imgDir + imageObj1 + ".jpg";
}
function StartCycle() {
eval("document."+imgArray[num]+".src = "+imgArray[num]+".src");
num = num + 1;
if (num < len) {
setTimeout("StartCycle()", 1000);
}
}
but the problem is that when the page loads, the images load as thye would on any site (at random so to speak), and rather than load the images 1 by 1 in my order, it loads them then removes them 1 by 1. Why is that happening? It is like it is working, but in reverse. What am I missing?