PDA

View Full Version : How to write the syntax for the if statement


forgottenglory
07-20-2008, 06:28 PM
I guess, this would be pretty simply, except that I can't figure out the syntax. On the root timeline, using the if statement, I would like to have a button on stage, which when clicked checks which frame Flash is on. If it is on frame zero it goes to frame 2 and plays. If it is already at frame 5 and the button is clicked then nothing happens.

Is using the if statement the best way to do it or is there a more suitable alternative.

NB. I'm using Actionscript 2

Thanks.

_Aerospace_Eng_
07-20-2008, 07:21 PM
Something like this should get you started.
thebutton.onRelease = thebutton.onReleaseOutside = function()
{
if(_root._currentframe == 1)
{
gotoAndPlay(2);
}
else if(_root._currentframe == 5) // this else if isn't really needed as nothing will happen either way
{
// do nothing
}
}
You may have to use a couple of stop(); calls in your AS.

forgottenglory
07-20-2008, 11:16 PM
Thanks so much! I had omitted the _currentframe bit completely. No wonder it never worked for me!