# Simple Show / Hide Button

**URL:** https://forum.kirupa.com/t/simple-show-hide-button/2331
**Category:** flash
**Created:** [April 23, 2002, 4:47pm UTC](https://forum.kirupa.com/t/simple-show-hide-button/2331 "2002-04-23T16:47:39Z")
**Posts on this page:** 8
**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: [April 23, 2002, 4:47pm UTC](https://forum.kirupa.com/t/simple-show-hide-button/2331/1 "2002-04-23T16:47:39Z")

</div>

Hi,  
I working on an example in which I will have 1 button.  
When the scene loads I have a movie clip which I set \_visible = false. When you click the button once the hidden movie is shown. When you the the button a 2nd time the now visible movie is hidden & so on. I started out by creating a movie clip symbol & then put a button in it. I initialize the variable “condition” = 0 on the 1st frame of this move cip. I then dragged this movie clip to the main scene & added the following script:

on (press) {  
&nbsp &nbsp &nbsp &nbsp if (condition == 0) {  
&nbsp &nbsp &nbsp &nbsp \_root.insbox.\_visible = true  
&nbsp &nbsp &nbsp &nbsp condition == 10  
}}  
&nbsp &nbsp &nbsp &nbsp

on (press) {  
&nbsp &nbsp &nbsp &nbsp if (condition == 10) {  
&nbsp &nbsp &nbsp &nbsp \_root.insbox.\_visible = false  
&nbsp &nbsp &nbsp &nbsp condtion = 0  
}}

When you click the button the 1st time the movie clips becomes visible. When you click a 2nd time becomes invisible. Then it won’t work again from there.

Any suggestions?  
Thank you.  
Tim

---

<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 23, 2002, 5:23pm UTC](https://forum.kirupa.com/t/simple-show-hide-button/2331/2 "2002-04-23T17:23:35Z")

</div>

There’s a typo :

```auto
 on (press) {
        if (condition == 10) {
        _root.insbox._visible = false
        **condition = 0**
}}

```

---

<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 23, 2002, 5:35pm UTC](https://forum.kirupa.com/t/simple-show-hide-button/2331/3 "2002-04-23T17:35:32Z")

</div>

Thank you. Could it be that simple?  
Does the logic look good to you?

---

<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 23, 2002, 6:06pm UTC](https://forum.kirupa.com/t/simple-show-hide-button/2331/4 "2002-04-23T18:06:55Z")

</div>

yes it is that simple and yes the logic is good.

---

<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 23, 2002, 6:14pm UTC](https://forum.kirupa.com/t/simple-show-hide-button/2331/5 "2002-04-23T18:14:11Z")

</div>

Here’s the code:  
It’s not working for me & for something that should be so simple it’s driving me crazy. I going to upload the .fla in a sec. If you guy could take a look for me I’d appreciate it. You can find it at [members.aol.com/webclickusa/fla](http://members.aol.com/webclickusa/fla)  
Thanks again

on (press) {  
&nbsp &nbsp &nbsp &nbsp if (condition == 0) {  
&nbsp &nbsp &nbsp &nbsp \_root.insbox.\_visible = true  
&nbsp &nbsp &nbsp &nbsp condition = 10  
&nbsp &nbsp &nbsp &nbsp  
}}  
&nbsp &nbsp &nbsp &nbsp

on (press) {  
&nbsp &nbsp &nbsp &nbsp if (condition == 10) {  
&nbsp &nbsp &nbsp &nbsp \_root.insbox.\_visible = false  
&nbsp &nbsp &nbsp &nbsp condition = 0  
}}

---

<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 23, 2002, 6:19pm UTC](https://forum.kirupa.com/t/simple-show-hide-button/2331/6 "2002-04-23T18:19:57Z")

</div>

try

on(press){  
if(condition == true){  
\_root.insbox.\_visible = 0 //this makes it invisible  
condition = false  
}else{  
\_root.insbox.\_visible = 1 //this makes it visible  
condition = true  
}  
}

haven’t tried it cuz i’m not near my machine.

---

<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 23, 2002, 8:44pm UTC](https://forum.kirupa.com/t/simple-show-hide-button/2331/7 "2002-04-23T20:44:01Z")

</div>

Jubba,  
Thanks, much appreciated.  
working perfectly. Be forwarned, I may  
flood you with more questions as I try to learn  
AS.

Take care,  
Tim

---

<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 23, 2002, 10:50pm UTC](https://forum.kirupa.com/t/simple-show-hide-button/2331/8 "2002-04-23T22:50:21Z")

</div>

no problem my friend. I am happy to help.
