# Follow mouse with conditionals

**URL:** <https://forum.kirupa.com/t/follow-mouse-with-conditionals/63737>\
**Category:** flash\
**Created:** [September 9, 2004, 4:47pm UTC](https://forum.kirupa.com/t/follow-mouse-with-conditionals/63737 "2004-09-09T16:47:01Z")\
**Posts on this page:** 6\
**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/63737/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]

---

<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:** [September 9, 2004, 4:49pm UTC](https://forum.kirupa.com/t/follow-mouse-with-conditionals/63737/2 "2004-09-09T16:49:44Z")

</div>

Are these conditionals ok? When I preview the movie, it just doesn’t appear and disappear as it should be…

Can anyone help? I’ll appreciate a lot!!!

Thanks

---

<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:** [September 9, 2004, 5:14pm UTC](https://forum.kirupa.com/t/follow-mouse-with-conditionals/63737/3 "2004-09-09T17:14:03Z")

</div>

what’s yfinal - where you defined it?

---

<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:** [September 9, 2004, 5:33pm UTC](https://forum.kirupa.com/t/follow-mouse-with-conditionals/63737/4 "2004-09-09T17:33:16Z")

</div>

Forget that last part of code, in fact “yfinal” is incorrect. I’m using the same code of the other MC, the variable is “endY” I want toknow if the conditional is well constructed. Here is the file.

---

<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:** [September 9, 2004, 7:38pm UTC](https://forum.kirupa.com/t/follow-mouse-with-conditionals/63737/5 "2004-09-09T19:38:58Z")

</div>

From a quick look at it… I think I know what the problem is.  
I mean… I didn’t quite understood what is your final purpose but…

the if condition is just fine… but as long as it is true, with every enterframe it will execute again and again the \_root.folower1.gotoandPlay(“rollover”);  
so… because is executed each frame… you won’t get to see the animation.

I hope I cleared at least a little bit your problem :).

---

<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:** [September 9, 2004, 9:53pm UTC](https://forum.kirupa.com/t/follow-mouse-with-conditionals/63737/6 "2004-09-09T21:53:11Z")

</div>

Thanks Virusescu…

Preciselly that’s what we were figuring out at this time. Any way, I’m triying something else, different codification…

Thanks again…!  
:ne:
