Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

load random images

Status
Not open for further replies.

greengrassbrian

Technical User
Mar 26, 2004
33
US
Hello all,

For the home page of my site there is a main image displayed. What I would like to do is have 5-10 images on the site that will randomly load whenever someone visits.

It doesn't need to be a slideshow - When someone visits they see image1, but then the next time they go they see image3, and then when they refresh they see image8.

here's my site:

here's how i want the image to work:

Thanks!
 
Alternatively: if you don't really care if they randomly get the same image twice you could simply randomize a number and load the image based on the random number. Example:

Code:
var randomImage:Number = random(7);
loadMovie("images/image"+randomImage+".jpg");

Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 
i've tried this...it seems to work except it won't load image1.jpg....any ideas why?

// create random number
randomnumber = Math.ceil(Math.random()*3);
// load image
url = "image"+randomnumber+".jpg";
loadMovie(url, fotoholder);
//


greengrassstudios.com/animationtest.html
 
no idea at all

Code:
for(i=0;i<20;i++){
randomnumber = Math.ceil(Math.random()*3);
trace(randomnumber)
}

throws up 1's
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top