# \[FMX\] Random Background tutorial

**URL:** https://forum.kirupa.com/t/fmx-random-background-tutorial/33471
**Category:** flash
**Created:** [October 20, 2003, 12:16am UTC](https://forum.kirupa.com/t/fmx-random-background-tutorial/33471 "2003-10-20T00:16:40Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![beatgenxer](https://avatars.discourse-cdn.com/v4/letter/b/f9ae1b/32.png) [@beatgenxer](https://forum.kirupa.com/u/beatgenxer)
#### Post date: [October 20, 2003, 12:16am UTC](https://forum.kirupa.com/t/fmx-random-background-tutorial/33471/1 "2003-10-20T00:16:40Z")

</div>

I’ve just completed the random background tutorial (thanks for making it so easy to follow!)

My questions are:

1. Is there a way to alter the code so it’s not random, but instead follows a preset list of images? So, instead of pressing a button and randomly choosing from the 5 images, it would go through the list starting with image0

2. Is there a way to preload the first image so it shows up when the viewer goes to the main page (where the background changes first occur)?

3. If someone goes to a new scene within the larger movie, would I have to place the same code and button on every page and the viewer would have to load the background image every time?

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: [October 22, 2003, 3:45am UTC](https://forum.kirupa.com/t/fmx-random-background-tutorial/33471/2 "2003-10-22T03:45:08Z")

</div>

no one has an answer yet?

---

<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: [October 22, 2003, 4:41am UTC](https://forum.kirupa.com/t/fmx-random-background-tutorial/33471/3 "2003-10-22T04:41:07Z")

</div>

```auto
choice = Math.round(Math.random()*5);
switch (choice) {
case 0 :
	location.loadMovie("image0.swf");
	break;
case 1 :
	location.loadMovie("image1.swf");
	break;
case 2 :
	location.loadMovie("image2.swf");
	break;
case 3 :
	location.loadMovie("image3.swf");
	break;
case 4 :
	location.loadMovie("image4.swf");
	break;
case 5 :
	location.loadMovie("image5.swf");
	break;
}

```

I would do something like

```auto
choice = Number

```

See if that works. My AS level is medium but I don’t know anything about switch case stuff.
