I’m having a mountain of trouble with an image cycling script. It works fine in IE and FF/Moz if you’re only cycling a single image, but as soon as you introduce another image to the equation, FF/Moz becomes choppy and horrible. Anyone have any ideas as to where I’m going wrong?
[code=html]
<html>
<head>
<script language=”javascript” type=”text/javascript”>
<!–
imagecycle.Vars = [];
imagecycle.preload = 0;
function imagecycle(id, pix, linx, delay, imgname)
{
this.howMany = pix.length;
this.id = id;
this.pix = pix;
this.preloadPix(this.pix);
this.linx = linx;
this.imgname = imgname;
this.delay = delay * 500;
this.picCurrentNum = 0;
this.picCurrent = new Image();
this.picCurrent.src = this.pix[this.picCurrentNum];
imagecycle.Vars[id] = this;
}
imagecycle.prototype.preloadPix = function(pix)
{
if (imagecycle.preload == 1) {
temp_img = new Image();
for (a=0; a<pix.length; a++) {
temp_img.src = pix[a];
}
}
}
imagecycle.startPix = function()
{
var reg = imagecycle.Vars;
for (a=0; a<reg.length; a++) {
obj = imagecycle.Vars[a];
interval = setInterval(“imagecycle.slideShow(“+obj.id+”)”, obj.delay);
}
}
imagecycle.slideShow = function(id)
{
var reg = imagecycle.Vars;
var obj = imagecycle.Vars[id];
obj.picCurrentNum++;
if (obj.picCurrentNum == obj.howMany) {
obj.picCurrentNum = 0;
}
obj.picCurrent.src = obj.pix[obj.picCurrentNum];
document[obj.imgname].src = obj.picCurrent.src;
}
imagecycle.link = function(id)
{
var reg = imagecycle.Vars;
var obj = imagecycle.Vars[id];
document.location = obj.linx[obj.picCurrentNum];
}
images1 = new Array(2);
images1[0] = “test1.jpg”;
images1[1] = “test2.jpg”;
links1 = new Array(2);
links1[0] = “#”;
links1[1] = “#”;
new imagecycle(0, images1, links1, 5, “test1”);
images2 = new Array(3);
images2[0] = “test3.jpg”;
images2[1] = “test4.jpg”;
images2[2] = “test5.jpg”;
links2 = new Array(2);
links2[0] = “#”;
links2[1] = “#”;
links2[2] = “#”;
new imagecycle(1, images2, links2, 3, “test2″);
// End –>
</script>
</head>
<body onload=”imagecycle.startPix()”>
<img width=”200″ height=”150″ name=”test1″ src=”test1.jpg” /><br />
<img width=”200″ height=”150″ name=”test2″ src=”test3.jpg” />
</body>
</html>