# If statement for open/close window

**URL:** <https://forum.kirupa.com/t/if-statement-for-open-close-window/111534>\
**Category:** Uncategorized\
**Created:** [May 27, 2004, 11:11pm UTC](https://forum.kirupa.com/t/if-statement-for-open-close-window/111534 "2004-05-27T23:11:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![seanc](https://avatars.discourse-cdn.com/v4/letter/s/ad7895/32.png) [@seanc](https://forum.kirupa.com/u/seanc)\
**Post date:** [May 27, 2004, 11:11pm UTC](https://forum.kirupa.com/t/if-statement-for-open-close-window/111534/1 "2004-05-27T23:11:21Z")

</div>

i have a button that has an if statement on it so when clicked it makes a contact box appear (note this is all in the same fla file, not a new browser window). i tried writing another if statement so that if you click the button again, the contact box will close but it isnt working. the way i’m doing it so far is…i have set up the contact box movie clip to have a blank keyframe on frame 1 with a stop on it, then the contact info is on frame 2 with another stop on it. here is the script that i put on the button. (the conact box is instance named “contactwin” :

on (release) {  
if (contactwin.\_currentframe == 1) {  
tellTarget (“contactwin”) {  
gotoAndPlay(2);  
}  
}  
}  
on (release) {  
if (contactwin.\_currentframe == 2) {  
tellTarget (“contactwin”) {  
gotoAndPlay(1);  
}  
}  
}

i notice if i remove the second part of the script and test the file, the contact box DOES appear. However, when the second part of the script is in there, the button does nothing. anyone have any idea what im doin wrong?

---

<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:** [May 27, 2004, 11:15pm UTC](https://forum.kirupa.com/t/if-statement-for-open-close-window/111534/2 "2004-05-27T23:15:03Z")

</div>

This probably won’t do anything but what happens if you change gotoAndPlay to gotoAndStop?

:hr:

---

<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:** [May 27, 2004, 11:40pm UTC](https://forum.kirupa.com/t/if-statement-for-open-close-window/111534/3 "2004-05-27T23:40:33Z")

</div>

i figured it out, the second if statement needed to be an “else” statement instead. :ogre:

---

<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:** [May 28, 2004, 12:42am UTC](https://forum.kirupa.com/t/if-statement-for-open-close-window/111534/4 "2004-05-28T00:42:46Z")

</div>

glad to see you figured it out 😉
