# If and else if?

**URL:** <https://forum.kirupa.com/t/if-and-else-if/21040>\
**Category:** Uncategorized\
**Created:** [May 16, 2003, 5:01am UTC](https://forum.kirupa.com/t/if-and-else-if/21040 "2003-05-16T05:01:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Felipe\_Bastos](https://avatars.discourse-cdn.com/v4/letter/f/f05b48/32.png) [@Felipe\_Bastos](https://forum.kirupa.com/u/Felipe_Bastos)\
**Post date:** [May 16, 2003, 5:01am UTC](https://forum.kirupa.com/t/if-and-else-if/21040/1 "2003-05-16T05:01:25Z")

</div>

Hi. My problem is the following - I`m trying to use the if condition to activate two menus, menu01 and menu02, that are in the same Y position on the stage. If my ymouse position (considering the _root._ymouse position) is greater than 400 (ymouse > 400) and less than 420 (ymouse < 420), both menus are opened. The condition to open menu01 (on the leftside) and not menu02 (rightside) is the xmouse position. Xmouse > 0 and < 360 would open menu01 and Xmouse > 360 and < 720 would open menu02. I tryied some code but I`m having some doubts about if conditions.  
Here is what I`ve done:

onClipEvent(enterFrame) {  
// impoe a condicao que determina a posicao Y do menu principal  
if (root.\_ymouse \> 400) {  
} else if (root.\_xmouse \> 0 && root.\_xmouse \< 360) {  
\_root.menu01.posY = 400;  
}  
}

Was I clear?  
Thankx

---

<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 16, 2003, 6:11am UTC](https://forum.kirupa.com/t/if-and-else-if/21040/2 "2003-05-16T06:11:01Z")

</div>

I`ve made some advances but than I found out another problem. The menu01, which contains several links (from \_x=0 till \_x=720) goes over the area (360 \< x \> 720) that also activate the menu02 and covers menu01 activated before.  
Is this the best way to do this? Using the x and y mouse position to activate menus? Does someone knows any better solution?  
Thankx again

---

<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 16, 2003, 3:36pm UTC](https://forum.kirupa.com/t/if-and-else-if/21040/3 "2003-05-16T15:36:39Z")

</div>

I see it`s confusing to explain my project. So if someone wants to help me, please send me an e-mail (felipe@nwi.com.br), subject cd-rom help, and I will reply with the swf file. I think this will be a better way.

Thankx

---

<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 16, 2003, 4:47pm UTC](https://forum.kirupa.com/t/if-and-else-if/21040/4 "2003-05-16T16:47:26Z")

</div>

Trying again. 🙂  
How can I write the following in AS. If ymouse \> 400 and xmouse \< 360, activate menu01. If ymouse \> 400 and xmouse \> 360, activate menu02 ?  
Is the if and else if condition the right way? Please, if you want to help me, read the previous post. Thankx

---

<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 16, 2003, 4:48pm UTC](https://forum.kirupa.com/t/if-and-else-if/21040/5 "2003-05-16T16:48:10Z")

</div>

I not quite sure what you trying tsay, but why dont you try:

on (rollOver) {  
}

(Which just means,when the mouse cursor is over the object the script is added to, Such and such happens.)

And:

on(rollOut){  
}

(Which just means,when the mouse cursor is not over the object the script is added to, such and such happens.)

I hope this helps.

---

<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 16, 2003, 4:56pm UTC](https://forum.kirupa.com/t/if-and-else-if/21040/6 "2003-05-16T16:56:21Z")

</div>

Yeh. Thats one way I`ve already done. But this time I`m trying to do this using the mouse position, so that I dont need to create any graphics.  
Thankx a lot!
