View Full Version : (FMX) if and else if..... not functioning right...going crazy
kaykills
May 16th, 2003, 10:02 PM
Hey,
i don't know if you can help me....... I am having a problem getting an if and else if statement to work.
if (sched = 05-23-03) {
gotoAndPlay(40);
}
else if (sched = 05-26-03) {
gotoAndPlay(41);
}
when you click a button in another movie clip, i set the variable on the button..... it then goes to the above clip and plays through to frame 20...... on frame 20 i have the above code......... when i test this no matter which of the 2 buttons i click it always goes to frame 40...... when i click that 2nd button it won't go to frame 41.
Can anyone help!?!?!?
Cheers
Michael
senocular
May 16th, 2003, 10:07 PM
use == instead of =
also do you want to check for 5 minus 23 minus 3 (-21) or "05-23-03" ?
thoriphes
May 16th, 2003, 10:15 PM
yeah, what sen said:
if (sched == "05-23-03") {
gotoAndPlay(40);
}
else if (sched == "05-26-03") {
gotoAndPlay(41);
}
kaykills
May 16th, 2003, 10:45 PM
thank you.... one more question..... do i have to put the value in " " when i am seting the variable as well?
senocular
May 16th, 2003, 10:46 PM
yes, otherwise you'll have a math operation
kaykills
May 16th, 2003, 10:50 PM
sen.... don't mean to keep bothering you..... but now it seems to ignore the if and else statement...... the button now looks like this
on (release) {
set (sched,"05-23-03");
_root.matchDetails.play(2);
}
and the movie matchDetails play up to frame 20 and then i have this
if (sched == "05-23-03") {
gotoAndPlay(40);
}
else if (sched == "05-26-03") {
gotoAndPlay(41);
}
it just skips right over it
thoriphes
May 16th, 2003, 11:09 PM
why do some people still use the old flash 4 style for actionscripting: set (blah1, blah2) instead of blah1 = blah2; ???
jeez people, get with the times :P, but hey don't change because of me, do whatever floats your boat.
senocular
May 17th, 2003, 06:16 AM
you need to set sched in matchDetails or use _root.sched == in the comparison. When you use just sched in matachDetails it looks for the varaible defined inside the matachDetails timeline called "sched" That varaible, however, you set in the button in _root so it doesnt exist in matachDetails (but, rather _root). So when matchDetails looks for it, it cant find it. Putting _root. before sched will force matchDetails to look in _root for sched and use the actual value you set for it there.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.