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

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 !!! :smirk:

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);
}

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 !