Random image

I was wondering if someone could help me out with this…I want to have a different image load on my home page everytime the page refreshes or someone visits it.

Is it possible to do it without using Flash?

Any help would be great.

Thanks

Yeah, what you have to do first is rename each of the possible images you want to load similar to this:[list][]pic1.jpg[]pic2.jpg[]pic3.jpg[]…[/list]
Basically, you want to put some number sequence after the filenames; you’ll see why in a sec.

Now in (preferably) the first frame, put this code in:

MovieClip.prototype.loadRandomPic = function (__url, picname, numpics) {
this.__url = __url;
this.__url += picname+String(random(numpics)+1);
this.loadMovie(this.__url);
};

Now, create an empty movieclip and place it where you want the image to be. Now, set the actions of this empty movieclip as so:

onClipEvent (load) {
this.loadRandomPic(/*url of the folder with the images with a slash (/) at the end*/, /*name of image sequeces (in example above 'pic'*/, /*number of images total (again, in the example, 3)*/);
}

so if you had pics named the same way above in the folder microsoft.com/images/, you’d call the function like this:

onClipEvent (load) {
this.loadRandomPic("http://www.microsoft.com/images/", "pic", 3);
}

and that code should choose from any of the three images named above.

let me know how it goes.

Thanks thoriphes

Is it possible to do it without using Flash though?

Thanks

oh god, i’m so sorry, i missed that “without flash” doo-da.

hm…you may have to ask someone else because i’m not as knowledgable outside actionscript.

sorry :frowning:

That’s ok…that’s why I posted it in the Random forum…but for some reason it got moved to this forum??

yeah, i moved it. i’ll move it back, sorry for the misunderstanding.

Hey evader,
Kitiara created a random image feature in JavaScript. You can find it here: http://www.kirupaforum.com/forums/showthread.php?s=&threadid=23363

Cheers!
Kirupa :thumb:

and this should be in the SCRIPTING forum… i’ll move it there…

I posted another method of this in this thread…

http://www.kirupaforum.com/forums/showthread.php?s=&threadid=18323

Thanks for all the help guys…sorry for all the confussion about what forum it should be in…lol