Button have multiple functions? On and Off?

Hey all,

I have two simple buttons on my movie clip (‘ON’ and ‘OFF’) that when clicked, change the ._visible state of the movie clip. Thing is, I only want ONE button to turn it on and off. Is this possible?
Basically, I would need an if statement or something…like

on (release)
if (movieclip is visible)
{ turn visible to false;}
{ turn visible to true;}

something like that is what I want to do. All code for the same button.
Any help?


on (release) {
myMovieClip._visible ? myMovieClip._visible=false : myMovieClip._visible=true;

that should work… =)

wow, I had no idea you could use that kind of notation in AS. That’s pretty cool.
I’ll give it a shot tomorrow at school!

BTW- what is that statement saying exactly? If you could spell out what the “?” and the “:” mean that would be cool.
Is it just a check or something?

Thanks again!


i think you’ll understand it better this way:

on (release) {
if (myMovieClip._visible == true) {
myMovieClip._visible = false;
} else {
myMovieClip._visible = true;

it’s exactly the same thing. =)

Worked like a charm,

thanks much!

no problem. :wink: