# Load movie

**URL:** <https://forum.kirupa.com/t/load-movie/11396>\
**Category:** Uncategorized\
**Created:** [January 16, 2003, 4:48pm UTC](https://forum.kirupa.com/t/load-movie/11396 "2003-01-16T16:48:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rally9](https://avatars.discourse-cdn.com/v4/letter/r/e19b73/32.png) [@rally9](https://forum.kirupa.com/u/rally9)\
**Post date:** [January 16, 2003, 4:48pm UTC](https://forum.kirupa.com/t/load-movie/11396/1 "2003-01-16T16:48:56Z")

</div>

Hello.

I have a little problem. I want to know how to make random URL:s in Flash. Or load an movie randomly.

thanks  
/plankan

---

<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:** [January 16, 2003, 5:50pm UTC](https://forum.kirupa.com/t/load-movie/11396/2 "2003-01-16T17:50:58Z")

</div>

You have to use arrays!

```auto

yourarray = ["URL1", "URL2", "URL3", "ULR4"] //list all the URLs you want to choose from!

```

now if you want to go to a new url with a click on a button then use this code to choose a random one from them when a button is clicked!

```auto
 on(release) {
getURL(yourarray[Math.round(Math.random()*yourarray.length)]);
}

```

or if you want to load a new random movie then list the movies in an array like the URLs and use this piece of code to load a random one!

```auto
on(release) {
loadMovie(yourarray[Math.round(Math.random()*yourarray.length)], 0)
}

```

* * *

what this line : getURL(yourarray[Math.round(Math.random()\*yourarray.length)]);  
does is:  
Math.random \<-- picks a random number between 0 and _the lentgh of the array_ (note that the members in the array are counted “0, 1, 2, 3, etc.” NOT “1, 2, 3, 4, etc”!)  
Math.round \<-- rounds the random number to a good number like “9” or “2” not “9.93985743”! 🙂  
now if you would like to pick for example the fourth member in the array then you should use the code like this:  
getURL(yourarray[4]);  
and to load movie you have to load it onto/into (whatever) a movieclip like  
\_root.mymc.loadMovie  
then the movieclip “mymc” will be replaced with the contents of the loaded movie!

Cheers!😉

---

<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:** [January 17, 2003, 2:46pm UTC](https://forum.kirupa.com/t/load-movie/11396/3 "2003-01-17T14:46:20Z")

</div>

Thanks for the help. It worked.  
Now i wounder if i can make it so it both load an movie an make a “goto” in the same press? Is that impossible?

Thanks  
/plankan

---

<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:** [January 17, 2003, 3:08pm UTC](https://forum.kirupa.com/t/load-movie/11396/4 "2003-01-17T15:08:19Z")

</div>

Then you would have to use 2 arrays, one for loadmovie and one for getURL! For example array1, array2 or sth!  
just make 2 arrays with different names (current name “yourarray”)  
and use both actions, getURL and loadMovie, for the button like this:

on(release) {  
getURL(blablabla);  
\_root.something(blablabla);  
}

😉
