# Adapted Kirupa random loading background

**URL:** <https://forum.kirupa.com/t/adapted-kirupa-random-loading-background/29909>\
**Category:** flash\
**Created:** [September 1, 2003, 10:51pm UTC](https://forum.kirupa.com/t/adapted-kirupa-random-loading-background/29909 "2003-09-01T22:51:03Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![telegirl](https://avatars.discourse-cdn.com/v4/letter/t/b19c9b/32.png) [@telegirl](https://forum.kirupa.com/u/telegirl)\
**Post date:** [September 1, 2003, 10:51pm UTC](https://forum.kirupa.com/t/adapted-kirupa-random-loading-background/29909/1 "2003-09-01T22:51:03Z")

</div>

I’ve just followed the Kirupa random loading background tutorial and I am getting a syntax error in the actionscript. I want the random loading swf’s to load on top of the background, so I made the top layer the “location” movie clip with the actions to randomly load movie. The exact syntax error message I’m getting is as follows…Scene=Scene 1, Layer=location, Frame=1: Line 2: The JavaScript ‘switch’ construct is not supported  
switch (choice) {

---

<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:** [September 1, 2003, 10:54pm UTC](https://forum.kirupa.com/t/adapted-kirupa-random-loading-background/29909/2 "2003-09-01T22:54:03Z")

</div>

Can anyone tell me what I need to change the ‘switch’ contruct to so I can get this to work?

Thanks in advance,  
Telegirl

---

<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:** [September 1, 2003, 10:55pm UTC](https://forum.kirupa.com/t/adapted-kirupa-random-loading-background/29909/3 "2003-09-01T22:55:24Z")

</div>

what does your code look like?  
try using if-else instead of switch…

---

<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:** [September 1, 2003, 10:58pm UTC](https://forum.kirupa.com/t/adapted-kirupa-random-loading-background/29909/4 "2003-09-01T22:58:37Z")

</div>

my code…  
choice = Math.round(Math.random()\*5);  
switch (choice) {  
case 0 :  
location.loadMovie(“quote0.swf”);  
break;  
case 1 :  
location.loadMovie(“quote1.swf”);  
break;  
case 2 :  
location.loadMovie(“quote2.swf”);  
break;  
}

---

<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:** [September 1, 2003, 11:51pm UTC](https://forum.kirupa.com/t/adapted-kirupa-random-loading-background/29909/5 "2003-09-01T23:51:40Z")

</div>

I tried exchanging the ‘switch’ with ‘else-if’ and the code started to generate more error messages.

---

<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:** [September 2, 2003, 7:45am UTC](https://forum.kirupa.com/t/adapted-kirupa-random-loading-background/29909/6 "2003-09-02T07:45:00Z")

</div>

choice = Math.round(Math.random()\*5);  
if (choice==0) {  
location.loadMovie(“quote0.swf”);  
break;  
} else if (choice==1) {  
location.loadMovie(“quote1.swf”);  
break;  
} else if (choice==2) {  
location.loadMovie(“quote2.swf”);  
break;  
}

i know there’s a better way to do it, but this will work. 😛 Not sure what the break’s are for, but i kept them in.

---

<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:** [September 2, 2003, 7:59am UTC](https://forum.kirupa.com/t/adapted-kirupa-random-loading-background/29909/7 "2003-09-02T07:59:33Z")

</div>

try

```auto
choice = Math.round(Math.random()*5);
location.loadMovie("quote"+choice+".swf");

```

---

<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:** [September 2, 2003, 8:02am UTC](https://forum.kirupa.com/t/adapted-kirupa-random-loading-background/29909/8 "2003-09-02T08:02:06Z")

</div>

That won’t work if you only want things to happen when choice = 0, 1 or 2 as in the code, although I suspect that you do, and that that code was for demonstration purposes only.

---

<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:** [September 2, 2003, 4:17pm UTC](https://forum.kirupa.com/t/adapted-kirupa-random-loading-background/29909/9 "2003-09-02T16:17:08Z")

</div>

Jack\_knife,

I tried your script and it isn’t generating any errors…however when I test the movie it’s not loading the quote swf’s either. I published the movie, the quote swf’s are in the same folder, I’ve enabled simple actions too, so I don’t understand why this isn’t working now. I followed the Kirupa tutorial for random loading background exactly and have exchanged the action script from that with the one you posted. I wonder at this point if I am doing something else wrong. This is getting very frustrating…

---

<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:** [September 2, 2003, 9:05pm UTC](https://forum.kirupa.com/t/adapted-kirupa-random-loading-background/29909/10 "2003-09-02T21:05:04Z")

</div>

[AS]  
choice = Math.round(Math.random()\*5);  
switch (choice) {  
case 0 :  
location.loadMovie(“quote0.swf”);  
break;  
case 1 :  
location.loadMovie(“quote1.swf”);  
break;  
case 2 :  
location.loadMovie(“quote2.swf”);  
break;  
case 3:  
break;  
}  
[/AS]

Post your fla if you have more problems. You might be putting it in the wrong place or something similar.

By the way, break is a statement used to execute the loop or switch statement currently running. For example, if you have a for loop running and it hits the command break, it will immediately exit the loop.

---

<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:** [September 3, 2003, 2:07am UTC](https://forum.kirupa.com/t/adapted-kirupa-random-loading-background/29909/11 "2003-09-03T02:07:32Z")

</div>

“Switch” is causing me error messages and won’t work.

The zipped files can be downloaded at [http://www.hawaiiancow.com/flash\_files.html](http://www.hawaiiancow.com/flash_files.html) . For some reason the flash movie file needs to be opened from Flash and then saved in Flash. I don’t understand why, but this is the first time I’ve put files up on a site to download…I must be doing something wrong…I’m very new at all of this…

Thanks,  
Telegirl

---

<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:** [September 3, 2003, 2:13am UTC](https://forum.kirupa.com/t/adapted-kirupa-random-loading-background/29909/12 "2003-09-03T02:13:06Z")

</div>

plz upload the .FLA files, not the .SWF files or zips

---

<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:** [September 3, 2003, 2:57am UTC](https://forum.kirupa.com/t/adapted-kirupa-random-loading-background/29909/13 "2003-09-03T02:57:24Z")

</div>

Okay, all the .fla files are uploaded to the site… [http://hawaiiancow.com/flash\_files.html](http://hawaiiancow.com/flash_files.html)

---

<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:** [September 3, 2003, 3:12am UTC](https://forum.kirupa.com/t/adapted-kirupa-random-loading-background/29909/14 "2003-09-03T03:12:52Z")

</div>

thanks, that will help a ton, i’ll look at them tomorrow, right now i have to write a paper… ☹

---

<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:** [September 3, 2003, 3:15am UTC](https://forum.kirupa.com/t/adapted-kirupa-random-loading-background/29909/15 "2003-09-03T03:15:40Z")

</div>

Thanks so much…I really appreciate it! Good luck on your paper.

---

<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:** [September 3, 2003, 3:19am UTC](https://forum.kirupa.com/t/adapted-kirupa-random-loading-background/29909/16 "2003-09-03T03:19:51Z")

</div>

thanks… im gonna need it… lol 😛

---

<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:** [September 3, 2003, 7:35am UTC](https://forum.kirupa.com/t/adapted-kirupa-random-loading-background/29909/17 "2003-09-03T07:35:40Z")

</div>

Dont forget to give your location mc an instance name of **location**.[AS]location.loadMovie(“quote”+Math.round(Math.random()\*5)+".swf");[/AS]

---

<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:** [September 3, 2003, 4:38pm UTC](https://forum.kirupa.com/t/adapted-kirupa-random-loading-background/29909/18 "2003-09-03T16:38:03Z")

</div>

Hahaha…thank you So much…that’s Exactly what was missing! Time for me to do a Homer Simpson-esque “D’oh”! The movie’s loading the random quotes beautifullly now! My most profound appreciation to everyone for their help!!! 🙂

---

<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:** [September 3, 2003, 4:45pm UTC](https://forum.kirupa.com/t/adapted-kirupa-random-loading-background/29909/19 "2003-09-03T16:45:17Z")

</div>

welcome 😉
