Hi everyone,
I want that in every 5 sec a randon image loads in my site. How do I do that?
Fernando, from Brazil
Hi everyone,
I want that in every 5 sec a randon image loads in my site. How do I do that?
Fernando, from Brazil
img = ["pic1.jpg", "pic2.jpg", "pic3.jpg"];
loadimg = function () {
r = Math.floor(Math.random()*img.length);
emptyMovieClipInstanceName.loadMovie(img[r])
}
loadimgi = setInterval(loadimg, 5000);
don’t forget to replace emptyMovieClipInstanceName with the actual instance name of the movie clip where you want to load the images
and i’ve seen a few questions about this … you might want to try a search as well
hi kax… wellcome to kirupa zone
function randomLoading() {
_root.createEmptyMovieClip("holder", 1);
holder._x = 50;
holder._y = 50;
myArray = ["1.jpg", "2.jpg", "3.jpg", "4.jpg", "5.jpg"];
picker = Math.floor(Math.random()*(5));
_root.holder.loadMovie(myArray[picker]);
};
setInterval(randomLoading, 5000);{
put your jpg files in the same folder with your SWF… give it the name like 2.jpg… etc
i hope it helps…
hi kax… wellcome to kirupa zone
what ??
function randomLoading() {
_root.createEmptyMovieClip("holder", 1);
holder._x = 50;
holder._y = 50;
myArray = ["1.jpg", "2.jpg", "3.jpg", "4.jpg", "5.jpg"];
picker = Math.floor(Math.random()*(5));
_root.holder.loadMovie(myArray[picker]);
};
setInterval(randomLoading, 5000);{
first … i’d change this line
picker = Math.floor(Math.random()*(5));
to
picker = Math.floor(Math.random()*myArray.length);
second … that’s basically the same code i posted
hi kax… wellcome to kirupa zone
what??
i mean hi fspaiva… :sigh:
while i post my replay you did in the same time so i didn’t see your replay…
hmm … 14 mins difference … i wouldn’t say that we posted at the same time
:: Copyright KIRUPA 2024 //--