PDA

View Full Version : Help with "if" and "else" statements



scimitar255
February 11th, 2009, 09:46 PM
Ok, I'm sorry if this is a really basic problem, but I can't figure out for the life of me what is wrong.

I want to go to a "win" frame once I get a certain score right? So here's my code: (applied to the frame)

_root.score.text = 0;

if (_root.score.text=8) {
gotoAndStop("win");
} else {
(_root.score.text=0);
stop();
}

But the problem is every time i load it the score says 8 (and it takes me to the win message anyways). And if i put in two == signs, it runs normally but it doesn't take me to the win message.

Thanks in advance

~Lurker
February 11th, 2009, 10:00 PM
Try this:

_root.score.text = 0;
onEnterFrame = function() {
if (_root.score.text == 8) {
gotoAndStop("win");
}
}
stop();

The code may be a little messy because I just typed that down just now, but it should work properly.

nathan99
February 11th, 2009, 10:01 PM
http://n99creations.com/viewtutorial.php?id=1&p=16

http://n99creations.com/viewtutorial.php?id=1&p=14