# Randon images

**URL:** <https://forum.kirupa.com/t/randon-images/14558>\
**Category:** flash\
**Created:** [February 27, 2003, 7:22pm UTC](https://forum.kirupa.com/t/randon-images/14558 "2003-02-27T19:22:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![fspaiva](https://avatars.discourse-cdn.com/v4/letter/f/d07c76/32.png) [@fspaiva](https://forum.kirupa.com/u/fspaiva)\
**Post date:** [February 27, 2003, 7:22pm UTC](https://forum.kirupa.com/t/randon-images/14558/1 "2003-02-27T19:22:19Z")

</div>

Hi everyone,

I want that in every 5 sec a randon image loads in my site. How do I do that?

Fernando, from Brazil

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 27, 2003, 7:35pm UTC](https://forum.kirupa.com/t/randon-images/14558/2 "2003-02-27T19:35:41Z")

</div>

```auto
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 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 27, 2003, 7:49pm UTC](https://forum.kirupa.com/t/randon-images/14558/3 "2003-02-27T19:49:42Z")

</div>

hi kax… wellcome to kirupa zone 😉

```php
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… 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 27, 2003, 8:00pm UTC](https://forum.kirupa.com/t/randon-images/14558/4 "2003-02-27T20:00:36Z")

</div>

> hi kax… wellcome to kirupa zone 😉

what ?? 😛

```auto
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

```auto
picker = Math.floor(Math.random()*(5));

```

to

```auto
picker = Math.floor(Math.random()*myArray.length);

```

second … that’s basically the same code i posted 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 27, 2003, 8:35pm UTC](https://forum.kirupa.com/t/randon-images/14558/5 "2003-02-27T20:35:26Z")

</div>

> 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…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 27, 2003, 8:40pm UTC](https://forum.kirupa.com/t/randon-images/14558/6 "2003-02-27T20:40:56Z")

</div>

hmm … 14 mins difference … i wouldn’t say that we posted at the **same** time 😛
