hi, I need to modify the following code which randomly displays 5 arrays of images in one row. it works fine with just one array but with all of them it chokes. It should dipslay the first following: row of all first images, replaced by a row of all second images and so on
Thank you !
<html>
<head>
<SCRIPT language=JavaScript type=”text/javascript”>
<!–
// image file names go in these arrays
randomImgObj.set1 = new Array(“”image1.1.jpg”,”image2.1.jpg”,”image3.1.jpg”,”image4.1.jpg”,”image5.1.jpg”);
randomImgObj.set2 = new Array(“image1.2.jpg”,”image2.2.jpg”,”image3.2.jpg”,”image4.2.jpg”,”image5.2.jpg”);
randomImgObj.set3 = new Array(“image1.3.jpg”,”image2.3.jpg”,”image3.3.jpg”,”image4.3.jpg”,”image5.3.jpg”);
randomImgObj.set4 = new Array(“image1.4.jpg”,”image2.4.jpg”,”image3.4.jpg”,”image4.4.jpg”,”image5.4.jpg”);
randomImgObj.set5 = new Array(“image1.5.jpg”,”image2.5.jpg”,”image3.5.jpg”,”image4.5.jpg”,”image5.5.jpg”);
randomImgObj.imagesPath = “”;
randomImgObjs = []; // holds all random rotating image objects defined constructor
var q=5;
function randomImgObj(s) {
this.speed=s; this.ctr=0; this.timer=0;
this.index = randomImgObjs.length; randomImgObjs[this.index] = this;
this.animString = “randomImgObjs[” + this.index + “]”;
}
randomImgObj.prototype = {
addImages: function(ar) { // preloads images
this.imgObj.imgs = [];
for (var i=0; ar[i]; i++) {
this.imgObj.imgs[i] = new Image();
this.imgObj.imgs[i].src = randomImgObj.imagesPath + ar[i];
}
},
rotate: function() { // controls rotation
var ctr;
ctr = this.imgObj.imgs.length-q;
this.ctr = ctr;
if ( typeof this.imgObj.filters != “undefined” ) {
this.imgObj.style.filter = ‘blendTrans(duration=1)’;
if (this.imgObj.filters.blendTrans) this.imgObj.filters.blendTrans.Apply();
}
this.imgObj.src = this.imgObj.imgs[this.ctr].src;
if ( typeof this.imgObj.filters != “undefined” && this.imgObj.filters.blendTrans )
this.imgObj.filters.blendTrans.Play();
q–;
if (q==0) q=this.imgObj.imgs.length;
}
}
// sets up rotation for all defined randomImgObjs
randomImgObj.start = function() {
for (var i=0; i<randomImgObjs.length; i++)
randomImgObjs[i].timer = setInterval(randomImgObjs[i].animString + “.rotate()”, randomImgObjs[i].speed);
}
randomImgObj.setUpImg = function(imgAr, sp, w, h) {
var rotator, img, imgStr = “”;
rotator = new randomImgObj(sp);
randomImgObjs[randomImgObjs.length-1].imgAr = imgAr;
img = imgAr[0];
imgStr += ‘<img src=”‘ + randomImgObj.imagesPath + img + ‘” alt=”” ‘;
imgStr += ‘name=”img’ + (randomImgObjs.length-1) + ‘” width=”‘ + w + ‘” height=”‘ + h + ‘”>’;
document.write(imgStr);
}
function imgRandomRotate() {
for (var i=0; randomImgObjs[i]; i++) {
var rotator = randomImgObjs[i];
rotator.imgObj = document.images[“img” + i]; // get reference to the image object
rotator.addImages(rotator.imgAr);
rotator.rotate();
}
randomImgObj.start();
}
//–>
</SCRIPT>
</head>
<BODY onLoad=”imgRandomRotate()”>
<SCRIPT language=JavaScript type=”text/javascript”>
// images array, delay, width and height of images
randomImgObj.setUpImg(randomImgObj.set1, 1000, 125, 125);
// images array, delay, width and height of images
randomImgObj.setUpImg(randomImgObj.set2, 1000, 125, 125);
// images array, delay, width and height of images
randomImgObj.setUpImg(randomImgObj.set3, 1000, 125, 125);
// images array, delay, width and height of images
randomImgObj.setUpImg(randomImgObj.set4, 1000, 125, 125);
// images array, delay, width and height of images
randomImgObj.setUpImg(randomImgObj.set5, 1000, 125, 125);
</SCRIPT>
</BODY>
</html>