# If/else statement menu - Please Help!

**URL:** <https://forum.kirupa.com/t/if-else-statement-menu-please-help/183349>\
**Category:** Uncategorized\
**Created:** [March 26, 2006, 3:13am UTC](https://forum.kirupa.com/t/if-else-statement-menu-please-help/183349 "2006-03-26T03:13:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![asol](https://avatars.discourse-cdn.com/v4/letter/a/74df32/32.png) [@asol](https://forum.kirupa.com/u/asol)\
**Post date:** [March 26, 2006, 3:13am UTC](https://forum.kirupa.com/t/if-else-statement-menu-please-help/183349/1 "2006-03-26T03:13:56Z")

</div>

When you click on one of the button the movieclip is suppose to play “open” while the other movieclip is suppose to play “close” if they are open or play frame 1 if they’re not open. I don’t know why it’s not working. Please help!

[COLOR=#993300]var[/COLOR] menuState:[COLOR=#993300]Number[/COLOR] = [COLOR=#000000]0[/COLOR];

[COLOR=#993300]function[/COLOR] openBtnCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR]menuState == [COLOR=#000000]0[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]  
theBtn.[COLOR=#993300]gotoAndPlay[/COLOR]COLOR=#000000[/COLOR];  
menuState = [COLOR=#000000]1[/COLOR];  
[COLOR=#993300]trace[/COLOR]COLOR=#000000[/COLOR]  
[COLOR=#000000]}[/COLOR] [COLOR=#993300]else[/COLOR] [COLOR=#000000]{[/COLOR]  
theBtn.[COLOR=#993300]gotoAndPlay[/COLOR]COLOR=#000000[/COLOR]  
menuState = [COLOR=#000000]0[/COLOR];  
[COLOR=#993300]trace[/COLOR]COLOR=#000000[/COLOR]  
[COLOR=#000000]}[/COLOR]  
[COLOR=#000000]}[/COLOR]

[COLOR=#993300]function[/COLOR] closeBtnCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR]menuState == [COLOR=#000000]1[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]  
theBtn.[COLOR=#993300]gotoAndPlay[/COLOR]COLOR=#000000[/COLOR];  
menuState = [COLOR=#000000]0[/COLOR];  
[COLOR=#000000]}[/COLOR] [COLOR=#993300]else[/COLOR] [COLOR=#993300]if[/COLOR][COLOR=#000000]([/COLOR]menuState == [COLOR=#000000]1[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]  
theBtn.[COLOR=#993300]gotoAndStop[/COLOR]COLOR=#000000[/COLOR]  
menuState = [COLOR=#000000]0[/COLOR];  
[COLOR=#000000]}[/COLOR]  
[COLOR=#000000]}[/COLOR]  
btn0.[COLOR=#993300]onRelease[/COLOR] = [COLOR=#993300]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
openBtnCOLOR=#000000[/COLOR];  
[COLOR=#993300]trace[/COLOR]COLOR=#000000[/COLOR]  
[COLOR=#000000]}[/COLOR];

btn1a.[COLOR=#993300]onRelease[/COLOR] = [COLOR=#993300]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
openBtnCOLOR=#000000[/COLOR];  
closeBtnCOLOR=#000000[/COLOR];  
closeBtnCOLOR=#000000[/COLOR];  
[COLOR=#000000]}[/COLOR];  
btn2a.[COLOR=#993300]onRelease[/COLOR] = [COLOR=#993300]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
openBtnCOLOR=#000000[/COLOR];  
closeBtnCOLOR=#000000[/COLOR];  
closeBtnCOLOR=#000000[/COLOR];  
[COLOR=#000000]}[/COLOR];  
btn3a.[COLOR=#993300]onRelease[/COLOR] = [COLOR=#993300]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
openBtnCOLOR=#000000[/COLOR];  
closeBtnCOLOR=#000000[/COLOR];  
closeBtnCOLOR=#000000[/COLOR];  
[COLOR=#000000]}[/COLOR];

---

<div class="post-metadata">

**Author:** ![RichL](https://avatars.discourse-cdn.com/v4/letter/r/e79b87/32.png) [@RichL](https://forum.kirupa.com/u/RichL)\
**Post date:** [March 30, 2006, 11:09am UTC](https://forum.kirupa.com/t/if-else-statement-menu-please-help/183349/2 "2006-03-30T11:09:59Z")

</div>

i can see one problem you have…in function closeBtn both options are testing for menuState ==1…not sure if that is your only problem though…

---

<div class="post-metadata">

**Author:** ![Soig](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Soig](https://forum.kirupa.com/u/Soig)\
**Post date:** [March 30, 2006, 2:49pm UTC](https://forum.kirupa.com/t/if-else-statement-menu-please-help/183349/3 "2006-03-30T14:49:55Z")

</div>

I agree, you really should use Boolean values to keep things clear.

> if(menuState == true)

Also, I’m not sure if this is what is messing you up

> trace(menuState)\<– Semicolon should be there
