[FMX] Button that toggles MC on/off?

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:

  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

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.