# If else "button problem"

**URL:** <https://forum.kirupa.com/t/if-else-button-problem/297930>\
**Category:** Uncategorized\
**Created:** [October 10, 2009, 4:25pm UTC](https://forum.kirupa.com/t/if-else-button-problem/297930 "2009-10-10T16:25:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![michaelafoley](https://avatars.discourse-cdn.com/v4/letter/m/3be4f8/32.png) [@michaelafoley](https://forum.kirupa.com/u/michaelafoley)\
**Post date:** [October 10, 2009, 4:25pm UTC](https://forum.kirupa.com/t/if-else-button-problem/297930/1 "2009-10-10T16:25:07Z")

</div>

Hello, I need some help.  
I have three buttons, btn\_1,btn\_2,btn\_3, and two movie clips, image\_1,image\_2. The names listed btn\_1,btn\_2,btn\_3, image\_1,image\_2. are all instance names. All buttons and movie clips are on their own layer in a single frame on the main time line. the movie clips have a stop action on the first and last frame, with a frame label, on the first frame in the sub time line. For image\_1 the frame label is image\_1\_1 and for image\_2 the frame label is image\_2\_1.  
I would like btn\_1 and btn\_2 to control the movie clips, image\_1,image\_2. Either button should be able to close the other buttons movie clip and play it’s own movie clip. Also i am trying to make the movie clips themselves have the ability to be closed by clicking on the movie clip image area that is playing. Both movie clips when not playing hide behind the appropriate button with an alfa of 0. When playing they expand to the middle of the window and are at 100% alfa, using a tween. The third button, btn\_3 should only be visible when one or the other movie clisp are playing. btn\_3 dose nothing else but this for now.  
As of now, my movies continuously loop and btn\_3 is always visible. I can’t seem to figure this out. my code for this action is:

var button1Open:Boolean = false;  
var button2Open:Boolean = false;

btn\_3.visible = false;

//_ **button 2** _\  
btn\_2.addEventListener(MouseEvent.CLICK, bClick);  
btn\_2.buttonMode = true;

function bClick(e:MouseEvent):void  
{  
image\_2.gotoAndPlay(“image\_2\_1”);  
image\_1.gotoAndStop(“image\_1\_1”);

```
if (button2Open == false)

```

{  
button2Open = true;  
}  
else  
{  
button2Open = false;  
}

if ((button2Open == true) && (button1Open == true))  
{  
btn\_3.visible = true;  
else  
{  
btn\_3.visible = false;  
}

}

image\_2.addEventListener(MouseEvent.CLICK, eClick);  
image\_2.buttonMode = true;

function eClick(e:MouseEvent):void{  
image\_2.gotoAndStop(“image\_2\_1”);  
}

//_ **button 1** _\

btn\_1.addEventListener(MouseEvent.CLICK, cClick);  
btn\_1.buttonMode = true;

function cClick(e:MouseEvent):void  
{  
image\_1.gotoAndPlay(“image\_1\_1”);  
image\_2.gotoAndStop(“image\_2\_1”);

```
if (button1Open == false)

```

{  
button1Open = true;  
}  
else  
{  
button1Open = false;  
}

if ((button2Open == true) && (button1Open == true))  
{  
btn\_3.visible = true;  
else  
{  
btn\_3.visible = false;  
}  
}

image\_1.addEventListener(MouseEvent.CLICK, fClick);  
image\_1.buttonMode = true;

function fClick(e:MouseEvent):void{  
image\_1.gotoAndStop(“image\_1\_1”);  
}

//what am i doing wrong?
