# Load random flash movie

**URL:** <https://forum.kirupa.com/t/load-random-flash-movie/9897>\
**Category:** flash\
**Created:** [December 20, 2002, 2:19pm UTC](https://forum.kirupa.com/t/load-random-flash-movie/9897 "2002-12-20T14:19:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![fester8542](https://avatars.discourse-cdn.com/v4/letter/f/a183cd/32.png) [@fester8542](https://forum.kirupa.com/u/fester8542)\
**Post date:** [December 20, 2002, 2:19pm UTC](https://forum.kirupa.com/t/load-random-flash-movie/9897/1 "2002-12-20T14:19:12Z")

</div>

I was wandering if anyone knows a way to randomly load a flash movie into a specific place of the same dimensions.

I am creating a page where I have a spot for a flash movie, and I would like to randomly load 4-5 different animations into that space that would change randomly by refreshing the page.

Are there any tuts out there or does someone know how to do this?

Thanks in advance.

---

<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:** [December 20, 2002, 2:48pm UTC](https://forum.kirupa.com/t/load-random-flash-movie/9897/2 "2002-12-20T14:48:03Z")

</div>

You have to make an array!  
myarray = [“myswf1.swf”, “myswf2.swf”, “myswf3.swf”]  
like this.  
Now to load 'em use this action:  
loadMovie(myarray[Math.floor(Math.random()\*myarray.lentgh)], \<path\>);  
This picks a random movie from the array and loads it. They have to be put on the first frame of your movie or ona movieclip between onClipEvent(load){} handlers!

---

<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:** [December 20, 2002, 3:54pm UTC](https://forum.kirupa.com/t/load-random-flash-movie/9897/3 "2002-12-20T15:54:56Z")

</div>

Syko,

Thanks for the quick response.

I apologize buy my AS skills are incredibly weak. I tried to incorporate your code into my movie. I failed with flying colors.

If its not too much of an inconvienence, could you please take a loot at the attached zip and let me know what I am doing wrong?

thanks man.

---

<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:** [December 20, 2002, 4:12pm UTC](https://forum.kirupa.com/t/load-random-flash-movie/9897/4 "2002-12-20T16:12:55Z")

</div>

here is another way of loading random swfs  
just put that on the first frame and that it… ( and take out all the other actionscrip)

choice = Math.round(Math.random()\*2);  
switch (choice) {  
case 0 :  
loadMovie(“myswf1.swf”,0);  
break;  
case 1 :  
loadMovie(“myswf2.swf”,0);  
break;  
case 2 :  
loadMovie(“myswf3.swf”,0);  
break;  
}

Jakub K.

---

<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:** [December 20, 2002, 4:21pm UTC](https://forum.kirupa.com/t/load-random-flash-movie/9897/5 "2002-12-20T16:21:18Z")

</div>

THanks man!

That was exactly what I am looking for.

Much appreciated.

---

<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:** [December 20, 2002, 4:44pm UTC](https://forum.kirupa.com/t/load-random-flash-movie/9897/6 "2002-12-20T16:44:19Z")

</div>

ok… 🙂

---

<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:** [December 20, 2002, 5:03pm UTC](https://forum.kirupa.com/t/load-random-flash-movie/9897/7 "2002-12-20T17:03:36Z")

</div>

There is ton of other way you could do this… but the one i mentioned i think is great for beginners and easy to understand…

Jakub…
