# Follow mouse with conditionals

**URL:** <https://forum.kirupa.com/t/follow-mouse-with-conditionals/122021>\
**Category:** Uncategorized\
**Created:** [September 9, 2004, 4:47pm UTC](https://forum.kirupa.com/t/follow-mouse-with-conditionals/122021 "2004-09-09T16:47:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![disenopop](https://avatars.discourse-cdn.com/v4/letter/d/e99b99/32.png) [@disenopop](https://forum.kirupa.com/u/disenopop)\
**Post date:** [September 9, 2004, 4:47pm UTC](https://forum.kirupa.com/t/follow-mouse-with-conditionals/122021/1 "2004-09-09T16:47:01Z")

</div>

Hi everyone:

I’ve done a navigation bar (actually there are 2 of them, one over another), and have a movie clip (a semi-transparent rectangle) that follows mouse. Each navigation bar has its own “follower”. The hard thing for me to figure out is to determine a range in Y axis that tells this semi-transparent rectangle to appear and disappear. Here is the code for the bottom MC:

[font=Courier New]onClipEvent (load) {[/font]  
[font=Courier New]\_x = 0;[/font]  
[font=Courier New]speed = 8;[/font]  
[font=Courier New]}[/font]

[font=Courier New]onClipEvent (enterFrame) {[/font]  
[font=Courier New]endX = \_root.\_xmouse;[/font]  
[font=Courier New]endY = \_root.\_ymouse;[/font]  
[font=Courier New]\_x += (endY - \_x)/speed;[/font]

[font=Courier New]if (endY \>= 230){[/font]  
[font=Courier New]\_root.follower2.gotoAndPlay(“rollover”)[/font]  
[font=Courier New]}[/font]  
[font=Courier New]if (endY \<= 260){[/font]  
[font=Courier New]\_root.follower2.gotoAndPlay(“rollout”)[/font]  
[font=Courier New]}[/font]  
[font=Courier New]}[/font]

The top MC has the same code, except for the values in the conditionals:

[font=Courier New]if (yfinal \>= 200){  
\_root.follower1.gotoAndPlay(“rollover”)  
}  
if (yfinal \<= 230){  
\_root.follower1.gotoAndPlay(“rollout”)  
}  
}[/font]
