PDA

View Full Version : Need help with randomizer


Stillwell
11-11-2004, 01:45 PM
I'm trying to make a randomized 6 sided die, but I'm having some trouble. Here is my code:

on (release) {
num = Math.round(Math.random()*6);
if (num=0) {
terning.gotoAndStop(1);
}
if (num=1) {
terning.gotoAndStop(2);
}
if (num=2) {
terning.gotoAndStop(3);
}
if (num=3) {
terning.gotoAndStop(4);
}
if (num=4) {
terning.gotoAndStop(5);
}
if (num=5) {
terning.gotoAndStop(6);
}

It's placed on a button, and the die is a 6 frame movieclip, with a stop action on each frame. My problem is that it seems that the randomizer makes num equal 6 every single time, and I can't figure out why. :confused:

Any help is appreciated.

CyanBlue
11-11-2004, 07:41 PM
Um... Not sure who closed the thread, but in case somebody wonders... :)

You need to use == to compare the conditions within the if statement... That's probably what's missing in there... :)