(FMX) if and else if..... not functioning right...going crazy

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

use == instead of =

also do you want to check for 5 minus 23 minus 3 (-21) or “05-23-03” ?

yeah, what sen said:


if (sched == "05-23-03") {
gotoAndPlay(40);
}
else if (sched == "05-26-03") {
gotoAndPlay(41);
}

thank you… one more question… do i have to put the value in " " when i am seting the variable as well?

yes, otherwise you’ll have a math operation

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

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.

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.