View Full Version : random image
evader
July 6th, 2003, 09:45 PM
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
thoriphes
July 6th, 2003, 10:01 PM
Yeah, what you have to do first is rename each of the possible images you want to load similar to this: pic1.jpg pic2.jpg pic3.jpg ...
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.
evader
July 6th, 2003, 10:07 PM
Thanks thoriphes
Is it possible to do it without using Flash though?
Thanks
thoriphes
July 6th, 2003, 10:08 PM
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 :(
evader
July 6th, 2003, 10:26 PM
That's ok...that's why I posted it in the Random forum...but for some reason it got moved to this forum??
thoriphes
July 6th, 2003, 10:35 PM
yeah, i moved it. i'll move it back, sorry for the misunderstanding.
kirupa
July 6th, 2003, 10:43 PM
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:
Jubba
July 6th, 2003, 10:47 PM
and this should be in the SCRIPTING forum... i'll move it there...
lostinbeta
July 6th, 2003, 11:42 PM
I posted another method of this in this thread...
http://www.kirupaforum.com/forums/showthread.php?s=&threadid=18323
evader
July 7th, 2003, 12:45 AM
Thanks for all the help guys...sorry for all the confussion about what forum it should be in...lol
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.