# If/else statement help

**URL:** <https://forum.kirupa.com/t/if-else-statement-help/297942>\
**Category:** Uncategorized\
**Created:** [October 10, 2009, 11:20pm UTC](https://forum.kirupa.com/t/if-else-statement-help/297942 "2009-10-10T23:20:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dhalfbee](https://avatars.discourse-cdn.com/v4/letter/d/c68b51/32.png) [@dhalfbee](https://forum.kirupa.com/u/dhalfbee)\
**Post date:** [October 10, 2009, 11:20pm UTC](https://forum.kirupa.com/t/if-else-statement-help/297942/1 "2009-10-10T23:20:27Z")

</div>

Hi all, I’m having trouble figuring out what is wrong with my ActionScript. The script is set to open and close screens when a button is clicked, for the code below it works perfectly when opening or closing screen1 and closes screen2 while opening screen1 but it will not close screen3 while opening screen1. Obviously I am new to this and still learning so any assistance is greatly appreciated. Thanks in advance.

function toggleContent(event:MouseEvent) {

if (togglescreen.currentFrame == 1) {

if (togglescreen2.currentFrame != 1) { // if screen2 is open

togglescreen2.gotoAndPlay(10); // closes screen2

{

if (togglescreen3.currentFrame != 1) { // if screen3 is open

```
togglescreen3.gotoAndPlay(10); }// close screen3

```

}

}

togglescreen.gotoAndPlay(2); // open screen1

} else {

togglescreen.gotoAndPlay(10); // close screen1

}

}

toggle\_btn.addEventListener(MouseEvent.CLICK, toggleContent);
