# Change visiblity upon clicking a button

**URL:** <https://forum.kirupa.com/t/change-visiblity-upon-clicking-a-button/264644>\
**Category:** flash\
**Created:** [June 28, 2008, 4:27am UTC](https://forum.kirupa.com/t/change-visiblity-upon-clicking-a-button/264644 "2008-06-28T04:27:15Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![imvain2](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/imvain2/32/620_2.png) [@imvain2](https://forum.kirupa.com/u/imvain2)\
**Post date:** [June 28, 2008, 4:27am UTC](https://forum.kirupa.com/t/change-visiblity-upon-clicking-a-button/264644/1 "2008-06-28T04:27:15Z")

</div>

I have a mc tracking as a button with a working on(release) statement.

Within the on release statement is this code that doesn’t work for me:

\_root.playbtn.pause\_mc.\_visible = true;  
\_root.playbtn.play\_mc.\_visible = true;

The first layer of the button has a mc with instance called play\_mc  
And the second layer of the button with a mc instance called pause\_mc

The button instance on the stage is called playbtn.

thanks for your help

---

<div class="post-metadata">

**Author:** ![dlgamer](https://avatars.discourse-cdn.com/v4/letter/d/7993a0/32.png) [@dlgamer](https://forum.kirupa.com/u/dlgamer)\
**Post date:** [June 29, 2008, 12:24am UTC](https://forum.kirupa.com/t/change-visiblity-upon-clicking-a-button/264644/2 "2008-06-29T00:24:47Z")

</div>

Use the same movie clip for both buttons. Place each button picture on a different frame in the movie clip timeline. Then place the **stop();** command in each frame, then use this code in the main timeline:

```auto
playbtn.onRelease = function() {
    this.play();
}

```

this should fix your problem

---

<div class="post-metadata">

**Author:** ![imvain2](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/imvain2/32/620_2.png) [@imvain2](https://forum.kirupa.com/u/imvain2)\
**Post date:** [June 29, 2008, 3:22am UTC](https://forum.kirupa.com/t/change-visiblity-upon-clicking-a-button/264644/3 "2008-06-29T03:22:48Z")

</div>

thanks, i just noticed a very weird problem.

I created a new blank movie  
Imported two images  
Created a new mc  
put image 1 as frame 1 with stop(); in the frame  
put image 2 as frame 2 with stop(); in the frame  
dropped the new symbol on my stage and set it as a button  
when I run the movie, and put my mouseover the button, it acts like i have some mouseover action and changes frames

This is where I was going to use your code, but couldn’t get that far because of this problem.

its really odd.

---

<div class="post-metadata">

**Author:** ![dlgamer](https://avatars.discourse-cdn.com/v4/letter/d/7993a0/32.png) [@dlgamer](https://forum.kirupa.com/u/dlgamer)\
**Post date:** [June 29, 2008, 3:35am UTC](https://forum.kirupa.com/t/change-visiblity-upon-clicking-a-button/264644/4 "2008-06-29T03:35:28Z")

</div>

could you upload your flash file?

---

<div class="post-metadata">

**Author:** ![imvain2](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/imvain2/32/620_2.png) [@imvain2](https://forum.kirupa.com/u/imvain2)\
**Post date:** [June 29, 2008, 3:43am UTC](https://forum.kirupa.com/t/change-visiblity-upon-clicking-a-button/264644/5 "2008-06-29T03:43:04Z")

</div>

thanks

this is just the stupid button that I was having problems with.

---

<div class="post-metadata">

**Author:** ![Adam1](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@Adam1](https://forum.kirupa.com/u/Adam1)\
**Post date:** [June 29, 2008, 3:45am UTC](https://forum.kirupa.com/t/change-visiblity-upon-clicking-a-button/264644/6 "2008-06-29T03:45:38Z")

</div>

Here you go - just leave your movieclip as a movieclip (instead of a button) and all is well.

---

<div class="post-metadata">

**Author:** ![imvain2](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/imvain2/32/620_2.png) [@imvain2](https://forum.kirupa.com/u/imvain2)\
**Post date:** [June 29, 2008, 5:25pm UTC](https://forum.kirupa.com/t/change-visiblity-upon-clicking-a-button/264644/7 "2008-06-29T17:25:35Z")

</div>

That works out perfectly thank you!

I didn’t realize that non buttons can have onrelease

---

<div class="post-metadata">

**Author:** ![Adam1](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@Adam1](https://forum.kirupa.com/u/Adam1)\
**Post date:** [June 29, 2008, 5:46pm UTC](https://forum.kirupa.com/t/change-visiblity-upon-clicking-a-button/264644/8 "2008-06-29T17:46:56Z")

</div>

You’re welcome, and I personally would recommend to never use buttons. Back in Flash 4 you had to, but since then you’re better off using movieClips for everything. Well, that’s my personally choice anyway 🙂
