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