# \[FMX\] Button that toggles MC on/off?

**URL:** <https://forum.kirupa.com/t/fmx-button-that-toggles-mc-on-off/21041>\
**Category:** flash\
**Created:** [May 16, 2003, 5:15am UTC](https://forum.kirupa.com/t/fmx-button-that-toggles-mc-on-off/21041 "2003-05-16T05:15:42Z")\
**Posts on this page:** 3\
**Page:** 1

<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 16, 2003, 5:15am UTC](https://forum.kirupa.com/t/fmx-button-that-toggles-mc-on-off/21041/1 "2003-05-16T05:15:42Z")

</div>

Hi. I’m wanting a button that should open an MC and have it stay open, then when the button is clicked again the MC would close.

This is what I have, but it doesn’t seem to work at all…

SCENE ACTIONSCRIPT:

BlahMC.enabled = false

BUTTON ACTIONSCRIPT:

on (press) {  
if (BlahMC.enabled = false) {  
BlahMC.enabled = true  
BlahMC.gotoAndPlay(“Start”);  
} else {  
BlahMC.gotoAndPlay(“Stop”);  
}  
}

Any pointers are appreciated, I’m actionscript impaired :crazy:

---

<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 16, 2003, 9:32pm UTC](https://forum.kirupa.com/t/fmx-button-that-toggles-mc-on-off/21041/2 "2003-05-16T21:32:14Z")

</div>

1. carefull with you if conditionals,  
if (BlahMC.enabled = false) {

doesn’t check, it sets to false, should be  
if (BlahMC.enabled == false) { //double == !!!

2.you’re right to use an if check, but a variable, like a toggle, is easier to start with:  
toggle=false;  
on press  
if toggle (same as if toggle==true)  
goto stop  
toggle=!toggle (reverses the value)  
else (toggle = false)  
goto play  
toggle=!toggle  
…get the picture with this pseudo code?  
try to work it out.  
else

---

<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 16, 2003, 11:00pm UTC](https://forum.kirupa.com/t/fmx-button-that-toggles-mc-on-off/21041/3 "2003-05-16T23:00:49Z")

</div>

Thanks! Missing that extra equal sign was screwing it up. I’m not sure about the toggle deal you tried to explain, it looked a little confusing and didn’t try. I got things working perfect using this though:

on (press) {  
if (\_root.BlahMC.enabled==false) {  
\_root.BlahMC.enabled=true;  
\_root.BlahMC.gotoAndPlay(“Start”);  
} else {  
\_root.BlahMC.enabled=false;  
\_root.BlahMC.gotoAndPlay(“Stop”);  
}  
}

Thanks again.
