# \[MX\] AARGH. PROBLEM loading random swf (music)

**URL:** <https://forum.kirupa.com/t/mx-aargh-problem-loading-random-swf-music/9273>\
**Category:** flash\
**Created:** [December 8, 2002, 9:41pm UTC](https://forum.kirupa.com/t/mx-aargh-problem-loading-random-swf-music/9273 "2002-12-08T21:41:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![StrongBad](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@StrongBad](https://forum.kirupa.com/u/StrongBad)\
**Post date:** [December 8, 2002, 9:41pm UTC](https://forum.kirupa.com/t/mx-aargh-problem-loading-random-swf-music/9273/1 "2002-12-08T21:41:53Z")

</div>

Hi. I couldn’t find an existing thread or Tutorial on this.  
If there is one , pls gimme the link and tell me why this won’t work.

I’m trying to randomly load SWF files that I made  
(contains on/off buttons & looped music).

**So in my main timeline I put this code:**

var x;

x=(Math.random(3));

```
   if (x=1) {
loadMovieNum("soundtrack1.swf",10);		
   } else if (x=2) {
loadMovieNum("soundtrack2.swf",10);
	} 

```

The soundtrack1.swf ALWAYS loads, so perhaps my math is wrong. (After this works, I’ll link it to a blank target in main timeline for better positioning)

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:** [December 8, 2002, 9:50pm UTC](https://forum.kirupa.com/t/mx-aargh-problem-loading-random-swf-music/9273/2 "2002-12-08T21:50:07Z")

</div>

well first of all! you do not need  
“var x”  
just use  
x = Math.random()\*3  
the problem with that code is that you’ve messed up “=” and “==”  
“==” checks the value of a variable  
“=” assigns a value to a variable.  
so the final code should be like this!

x=Math.random(3);  
if (x==1) {  
loadMovieNum(“soundtrack1.swf”,10);  
} else if (x==2) {  
loadMovieNum(“soundtrack2.swf”,10);  
}

---

<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 9, 2002, 2:16am UTC](https://forum.kirupa.com/t/mx-aargh-problem-loading-random-swf-music/9273/3 "2002-12-09T02:16:15Z")

</div>

YEAH !!!

That seems to work now, I also discovered that I didn’t save the main file I was working with in the same directory as the SWF music files.

I made few minor changes and no it’s all good !
