# Button have multiple functions? On and Off?

**URL:** <https://forum.kirupa.com/t/button-have-multiple-functions-on-and-off/19405>\
**Category:** flash\
**Created:** [April 27, 2003, 8:18pm UTC](https://forum.kirupa.com/t/button-have-multiple-functions-on-and-off/19405 "2003-04-27T20:18:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Quattro](https://avatars.discourse-cdn.com/v4/letter/q/a6a055/32.png) [@Quattro](https://forum.kirupa.com/u/Quattro)\
**Post date:** [April 27, 2003, 8:18pm UTC](https://forum.kirupa.com/t/button-have-multiple-functions-on-and-off/19405/1 "2003-04-27T20:18:03Z")

</div>

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;}  
else  
{ turn visible to true;}  
}

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

Thanks!  
Q

---

<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:** [April 27, 2003, 8:25pm UTC](https://forum.kirupa.com/t/button-have-multiple-functions-on-and-off/19405/2 "2003-04-27T20:25:17Z")

</div>

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

```

that should work… =)

---

<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:** [April 28, 2003, 1:43am UTC](https://forum.kirupa.com/t/button-have-multiple-functions-on-and-off/19405/3 "2003-04-28T01:43:51Z")

</div>

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!

Q

---

<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:** [April 28, 2003, 1:53am UTC](https://forum.kirupa.com/t/button-have-multiple-functions-on-and-off/19405/4 "2003-04-28T01:53:33Z")

</div>

i think you’ll understand it better this way:

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

```

it’s exactly the same thing. =)

---

<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:** [April 28, 2003, 1:20pm UTC](https://forum.kirupa.com/t/button-have-multiple-functions-on-and-off/19405/5 "2003-04-28T13:20:34Z")

</div>

Worked like a charm,

thanks much!  
Q

---

<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:** [April 28, 2003, 1:25pm UTC](https://forum.kirupa.com/t/button-have-multiple-functions-on-and-off/19405/6 "2003-04-28T13:25:36Z")

</div>

no problem. 😉
