# Random image

**URL:** <https://forum.kirupa.com/t/random-image/24904>\
**Category:** programming\
**Created:** [July 7, 2003, 1:45am UTC](https://forum.kirupa.com/t/random-image/24904 "2003-07-07T01:45:26Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![evader](https://avatars.discourse-cdn.com/v4/letter/e/e9a140/32.png) [@evader](https://forum.kirupa.com/u/evader)\
**Post date:** [July 7, 2003, 1:45am UTC](https://forum.kirupa.com/t/random-image/24904/1 "2003-07-07T01:45:26Z")

</div>

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

---

<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:** [July 7, 2003, 2:01am UTC](https://forum.kirupa.com/t/random-image/24904/2 "2003-07-07T02:01:13Z")

</div>

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:

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

```auto
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/](http://microsoft.com/images/), you’d call the function like this:

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

---

<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:** [July 7, 2003, 2:07am UTC](https://forum.kirupa.com/t/random-image/24904/3 "2003-07-07T02:07:08Z")

</div>

Thanks thoriphes

Is it possible to do it without using Flash though?

Thanks

---

<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:** [July 7, 2003, 2:08am UTC](https://forum.kirupa.com/t/random-image/24904/4 "2003-07-07T02:08:47Z")

</div>

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 ☹

---

<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:** [July 7, 2003, 2:26am UTC](https://forum.kirupa.com/t/random-image/24904/5 "2003-07-07T02:26:08Z")

</div>

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

---

<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:** [July 7, 2003, 2:35am UTC](https://forum.kirupa.com/t/random-image/24904/6 "2003-07-07T02:35:09Z")

</div>

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

---

<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:** [July 7, 2003, 2:43am UTC](https://forum.kirupa.com/t/random-image/24904/7 "2003-07-07T02:43:55Z")

</div>

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](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=23363)

Cheers!  
Kirupa :thumb:

---

<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:** [July 7, 2003, 2:47am UTC](https://forum.kirupa.com/t/random-image/24904/8 "2003-07-07T02:47:01Z")

</div>

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

---

<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:** [July 7, 2003, 3:42am UTC](https://forum.kirupa.com/t/random-image/24904/9 "2003-07-07T03:42:42Z")

</div>

I posted another method of this in this thread…

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

---

<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:** [July 7, 2003, 4:45am UTC](https://forum.kirupa.com/t/random-image/24904/10 "2003-07-07T04:45:51Z")

</div>

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