Random integers

I have been playing around in flash trying the random code out but I don’t seem to be doing it right.
What I want to do: Have flash play through and at a certain frame create a random integer (either 1 or 2) and place it in a variable. ThenCheck that variable and if it’s 1 gotoAndPlay(certainframe) and if its 2 gotoAndPlay(anotherframe).
Here’s what I had tried. On a frame i put


number=random(2)
if(number=1){
gotoAndPlay(#);
}
if(number=2){
gotoAndPlay(#);
}

But, it seemed to always gotoAndPlay the second #. I tried it over 30 times and even had a box showing the variable and no matter what it went to the second frame #. I guess I just don’t know what to put to make this work. Not much work with random scripts so can anyone help me out?