# One button, two functions?

**URL:** <https://forum.kirupa.com/t/one-button-two-functions/63373>\
**Category:** flash\
**Created:** [September 6, 2004, 4:34am UTC](https://forum.kirupa.com/t/one-button-two-functions/63373 "2004-09-06T04:34:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arekaine](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@Arekaine](https://forum.kirupa.com/u/Arekaine)\
**Post date:** [September 6, 2004, 4:34am UTC](https://forum.kirupa.com/t/one-button-two-functions/63373/1 "2004-09-06T04:34:44Z")

</div>

Alright so I have this movie. And there is this little animation at the top that drops down and shows the page name. I also have two buttons that will allow the user to make the animation move up off the screen, and then if they want back down again. Both buttons work fine and the animation goes off with out a hitch.

Now what I would like to do is have just one button that does both of these things. Pretty much if the animation is down, they click the button, it goes up, and vice versa. I am pretty sure this would have something to do with the “if” and “else”. I have tried several diffrent times but either it won’t work or I get scripting errors.

Anyway here is the script I am using right now

//this will close the page header  
close\_btn.onRelease = function () {  
\_parent.page\_header.gotoAndPlay(“close”);  
};  
//this will open the page header  
open\_btn.onRelease = function () {  
\_parent.page\_header.gotoAndPlay(“down”);  
};

Pretty basic stuff. Any help would be most appriciated

---

<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:** [September 6, 2004, 5:36am UTC](https://forum.kirupa.com/t/one-button-two-functions/63373/2 "2004-09-06T05:36:35Z")

</div>

> [@Arekaine](#):
>
> Alright so I have this movie. And there is this little animation at the top that drops down and shows the page name. I also have two buttons that will allow the user to make the animation move up off the screen, and then if they want back down again. Both buttons work fine and the animation goes off with out a hitch.
> 
> Now what I would like to do is have just one button that does both of these things. Pretty much if the animation is down, they click the button, it goes up, and vice versa. I am pretty sure this would have something to do with the “if” and “else”. I have tried several diffrent times but either it won’t work or I get scripting errors.
> 
> Anyway here is the script I am using right now
> 
> //this will close the page header  
> close\_btn.onRelease = function () {  
> \_parent.page\_header.gotoAndPlay(“close”);  
> };  
> //this will open the page header  
> open\_btn.onRelease = function () {  
> \_parent.page\_header.gotoAndPlay(“down”);  
> };
> 
> Pretty basic stuff. Any help would be most appriciated

try  
myButton.onRelease = function() {  
(playing=!playing) ? \_parent.page\_header.gotoAndPlay(“close”) : \_parent.page\_header.gotoAndPlay(“down”);  
};

---

<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:** [September 8, 2004, 6:27pm UTC](https://forum.kirupa.com/t/one-button-two-functions/63373/3 "2004-09-08T18:27:21Z")

</div>

> [@Arekaine](#):
>
> Alright so I have this movie. And there is this little animation at the top that drops down and shows the page name. I also have two buttons that will allow the user to make the animation move up off the screen, and then if they want back down again. Both buttons work fine and the animation goes off with out a hitch.
> 
> Now what I would like to do is have just one button that does both of these things. Pretty much if the animation is down, they click the button, it goes up, and vice versa. I am pretty sure this would have something to do with the “if” and “else”. I have tried several diffrent times but either it won’t work or I get scripting errors.
> 
> Anyway here is the script I am using right now
> 
> //this will close the page header  
> close\_btn.onRelease = function () {  
> \_parent.page\_header.gotoAndPlay(“close”);  
> };  
> //this will open the page header  
> open\_btn.onRelease = function () {  
> \_parent.page\_header.gotoAndPlay(“down”);  
> };
> 
> Pretty basic stuff. Any help would be most appriciated

A)First frame actions: your script  
B)//Inside object button:  
on(release){  
//do something  
trace(“done!”)  
};

---

<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:** [September 8, 2004, 6:32pm UTC](https://forum.kirupa.com/t/one-button-two-functions/63373/4 "2004-09-08T18:32:59Z")

</div>

```auto
// initialize function variable
var myVar = isFalse;

switchEP = function() {
     if (myVar == "isTrue") {
          // do something
          myVar = isFalse;
     } else {
          // do something else
          myVar = isTrue;
     }
}

```

And then the AS for you MC:

```auto
myMC.onRelease = function() {
     switchEP();
}

```
