# If statement help

**URL:** <https://forum.kirupa.com/t/if-statement-help/26419>\
**Category:** flash\
**Created:** [July 22, 2003, 11:05pm UTC](https://forum.kirupa.com/t/if-statement-help/26419 "2003-07-22T23:05:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nickel](https://avatars.discourse-cdn.com/v4/letter/n/e9c0ed/32.png) [@nickel](https://forum.kirupa.com/u/nickel)\
**Post date:** [July 22, 2003, 11:05pm UTC](https://forum.kirupa.com/t/if-statement-help/26419/1 "2003-07-22T23:05:51Z")

</div>

I have a site with 4 submenus that load various swfs…what i need to do is make the buttons in the submenus stay in their rollover (active) states when clicked. I cant figure out how to write this with the script - Is there a way to tell the button to stay in its “active” state when it’s swf is loaded - and then go to its “normal” state when another button’s swf is loaded? I’m loading all the swfs into an empty movie clip called “content”. Here’s the site, only the 1st button (Philosophy) and 2nd (Passion) menus are working so far.

[http://www.bondcreates.com/flashtest/site.html](http://www.bondcreates.com/flashtest/site.html)

what i have done so far is put the buttons on a timeline so it would go to a frame with a dead “active” state of that button - but this won’t work because if you open another submenu (passion) and go back to (philosophy) it stays stuck on that dead “active” button while another swf might be loaded in the content…not good at all.

---

<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:** [July 23, 2003, 9:51am UTC](https://forum.kirupa.com/t/if-statement-help/26419/2 "2003-07-23T09:51:35Z")

</div>

make the button an mc with two frames, normal and over. instance name of ‘b1’. Add this code to the frame 1 of the MAIN timeline.

b1.clicked=false  
b1.onRollOver= function(){  
b1.gotoAndStop(2) }  
b1.onRollOut= function(){  
if(!b1.clicked) b1.gotoAndStop(1)}  
b1.onPress= function(){  
if(b1.clicked){  
b1.gotoAndStop(1)  
b1.clicked=false  
}  
else{  
b1.gotoAndStop(2)  
b1.clicked=true}}

---

<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:** [July 23, 2003, 1:46pm UTC](https://forum.kirupa.com/t/if-statement-help/26419/3 "2003-07-23T13:46:28Z")

</div>

Hey kartik, thanks for that reply. Is this possible with Flash 5? I showed a friend the script and he said it may not be…and that i’d have to code this for each button on my submenus - meaning i’d have 19 buttons in total. Would i just continue this code using “b1” all the way through “b19”?

---

<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:** [July 23, 2003, 2:56pm UTC](https://forum.kirupa.com/t/if-statement-help/26419/4 "2003-07-23T14:56:00Z")

</div>

onClipEvent(mouseMove){  
if(hitTest(\_root.\_xmouse,\_root.\_ymouse,false)){  
touch=true  
this.gotoAndStop(2)   
}  
else{  
if(touch==true){  
touch=false  
if(!clicked){  
this.gotoAndStop(1)  
}}}}  
onClipEvent(mouseDown){  
if(hitTest(\_root.\_xmouse,\_root.\_ymouse,false)){  
if(!clicked){  
clicked=true  
gotoAndStop(2)}   
}  
else{  
clicked=false  
gotoAndStop(1)  
}  
}

add this to your button mc.
