inchoate
07-14-2003, 03:25 PM
I'm trying to create the ability to click on an image and loop through an array of images. I know how to create the array but I can't seem to create the effect. Any ideas?
|
Click to See Complete Forum and Search --> : image loop on click inchoate 07-14-2003, 03:25 PM I'm trying to create the ability to click on an image and loop through an array of images. I know how to create the array but I can't seem to create the effect. Any ideas? Khalid Ali 07-14-2003, 05:01 PM how about getting a freeware animation program and create an animated gif...??? Else yu need to swap images using setTimeout function. David Harrison 07-14-2003, 05:12 PM Just for a laugh, I went away and wrote one. inchoate 07-15-2003, 11:35 AM Thank you for the time and suggestions. This is how I finally ended up with what I wanted. The original image is randomly chosen and after that it goes through the array. Thanks again. <SCRIPT LANGUAGE="javascript"> // make the array of images var homeImage = new Array(); homeImage[0] = "pictures/homepics/andes.jpg"; homeImage[1] = "pictures/homepics/andes2.jpg"; homeImage[2] = "pictures/homepics/andes3.jpg"; homeImage[3] = "pictures/homepics/andes4.jpg"; homeImage[4] = "pictures/homepics/cuzco stones.gif"; homeImage[5] = "pictures/homepics/weaver.jpg"; homeImage[6] = "pictures/homepics/weaver2.jpg"; homeImage[7] = "pictures/homepics/weaver3.jpg"; homeImage[8] = "pictures/homepics/weaver4.jpg"; homeImage[9] = "pictures/homepics/weaver5.jpg"; // make a variable to change out the images var num=0 // make a function to change the images function changeimg(){ change.src=homeImage[num]; if(num<9){num++;} else{num=0;change.src=homeImage[0];} } // create a random whole number to retrieve the orignally displayed image randomNumber = Math.floor(Math.random()* homeImage.length) // display the random image document.write("<a href='#' onClick='changeimg();return false;'><img src='" + homeImage[randomNumber] + "' border='3' name='change' alt='Home Image'></a>"); </script> David Harrison 07-15-2003, 12:47 PM Happy to help:) webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |