# Question reg: button?

**URL:** <https://forum.kirupa.com/t/question-reg-button/12118>\
**Category:** Uncategorized\
**Created:** [January 27, 2003, 8:20am UTC](https://forum.kirupa.com/t/question-reg-button/12118 "2003-01-27T08:20:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Audrius](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@Audrius](https://forum.kirupa.com/u/Audrius)\
**Post date:** [January 27, 2003, 8:20am UTC](https://forum.kirupa.com/t/question-reg-button/12118/1 "2003-01-27T08:20:31Z")

</div>

HI I have a question regarding button.  
I made a movie where button is clicked opens a door so when door opens i want to be able to close the door with the same button.  
Here is what I have right now:

on (release) {  
control.gotoAndStop(2);  
}  
So when door opens another button…

(on (release)  
{gotoAndPlay(1);  
}

…loads which when is clicked suppose to close the door. Everything works fine except I would like to close and open the door with same button.  
I am not sure if I explained well enough. I hope I did?

Any suggestions will greatly appreciated

Thanks

---

<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:** [January 27, 2003, 8:43am UTC](https://forum.kirupa.com/t/question-reg-button/12118/2 "2003-01-27T08:43:42Z")

</div>

try something like this:

```php

// create a variable to tell the button what to do
// if openDoor equals true .. open door
// if openDoor equals false .. close door
on (release) {
     if (!openDoor) {
          openDoor = true
     } else if (openDoor) {
          openDoor = false
     }
     if (openDoor) {
          doorInstanceName.gotoAndPlay ("frame when door opens")
     } else if (!openDoor) {
          doorInstanceName.gotoAndPlay ("frame when door closes")
     }
}

```

untested but it should work  
if not … post your file and i’ll fix it for you 😏

good luck !!
