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

**URL:** https://forum.kirupa.com/t/fmx-if-and-else-if-not-functioning-right-going-crazy/21099
**Category:** flash
**Created:** [May 17, 2003, 2:02am UTC](https://forum.kirupa.com/t/fmx-if-and-else-if-not-functioning-right-going-crazy/21099 "2003-05-17T02:02:55Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![kaykills](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kaykills/32/228_2.png) [@kaykills](https://forum.kirupa.com/u/kaykills)
#### Post date: [May 17, 2003, 2:02am UTC](https://forum.kirupa.com/t/fmx-if-and-else-if-not-functioning-right-going-crazy/21099/1 "2003-05-17T02:02:55Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 17, 2003, 2:07am UTC](https://forum.kirupa.com/t/fmx-if-and-else-if-not-functioning-right-going-crazy/21099/2 "2003-05-17T02:07:31Z")

</div>

use == instead of =

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 17, 2003, 2:15am UTC](https://forum.kirupa.com/t/fmx-if-and-else-if-not-functioning-right-going-crazy/21099/3 "2003-05-17T02:15:21Z")

</div>

yeah, what sen said:

```auto

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

```

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 17, 2003, 2:45am UTC](https://forum.kirupa.com/t/fmx-if-and-else-if-not-functioning-right-going-crazy/21099/4 "2003-05-17T02:45:47Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 17, 2003, 2:46am UTC](https://forum.kirupa.com/t/fmx-if-and-else-if-not-functioning-right-going-crazy/21099/5 "2003-05-17T02:46:12Z")

</div>

yes, otherwise you’ll have a math operation

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 17, 2003, 2:50am UTC](https://forum.kirupa.com/t/fmx-if-and-else-if-not-functioning-right-going-crazy/21099/6 "2003-05-17T02:50:04Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 17, 2003, 3:09am UTC](https://forum.kirupa.com/t/fmx-if-and-else-if-not-functioning-right-going-crazy/21099/7 "2003-05-17T03:09:01Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 17, 2003, 10:16am UTC](https://forum.kirupa.com/t/fmx-if-and-else-if-not-functioning-right-going-crazy/21099/8 "2003-05-17T10:16:56Z")

</div>

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.
