# \[FMX\] Following mouse only on Y axis

**URL:** <https://forum.kirupa.com/t/fmx-following-mouse-only-on-y-axis/8855>\
**Category:** Uncategorized\
**Created:** [November 29, 2002, 6:37pm UTC](https://forum.kirupa.com/t/fmx-following-mouse-only-on-y-axis/8855 "2002-11-29T18:37:26Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdipi](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/mdipi/32/49_2.png) [@mdipi](https://forum.kirupa.com/u/mdipi)\
**Post date:** [November 29, 2002, 6:37pm UTC](https://forum.kirupa.com/t/fmx-following-mouse-only-on-y-axis/8855/1 "2002-11-29T18:37:26Z")

</div>

hey guys! I finally got around to starting mdipiV[SIZE=1]2[/SIZE] but am now running into a problem.

I want the menu to follow the mouse, but only up and down. I just can’t figure out the code. so far is a simple start drag, in and onClipEvent handler… i can’t figure what to use…\_y, or \_ymouse. and where do i put it?

thanks in advance,  
mike

---

<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:** [November 29, 2002, 7:09pm UTC](https://forum.kirupa.com/t/fmx-following-mouse-only-on-y-axis/8855/2 "2002-11-29T19:09:30Z")

</div>

onClipEvent (load) {  
\_x = 0;  
\_y = 0;  
speed = 5;  
}  
onClipEvent (enterFrame) {  
endX = \_root.\_xmouse;  
endY = \_root.\_ymouse;  
\_x += (endX-\_x)/speed;  
\_y += (endY-\_y)/speed;  
}

just remove the \_y values or the \_x for what ever motion u want for example

onClipEvent (load) {  
\_x = 0;  
speed = 5;  
}  
onClipEvent (enterFrame) {  
endX = \_root.\_xmouse;  
endY = \_root.\_ymouse;  
\_x += (endX-\_x)/speed;  
}

this would make the movie clip folow the mouse only on the \_x axis at speed (5)

I use the same code in my Footer (see below)

---

<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:** [November 29, 2002, 7:30pm UTC](https://forum.kirupa.com/t/fmx-following-mouse-only-on-y-axis/8855/3 "2002-11-29T19:30:10Z")

</div>

Or if you’re feeling lazy and don’t wanna deal with the actionscripting then you can use Flash MX’s mouse follow component. I had to modify the AS a little on the component to make it follow the mouse just on the y axis cause the original had the object follow your mouse in all directions. I attached a fla for you to play with. Hope it 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:** [November 29, 2002, 9:14pm UTC](https://forum.kirupa.com/t/fmx-following-mouse-only-on-y-axis/8855/4 "2002-11-29T21:14:55Z")

</div>

elec that was perfect! thank you both! one :q: where can i dl the component?

---

<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:** [November 29, 2002, 9:18pm UTC](https://forum.kirupa.com/t/fmx-following-mouse-only-on-y-axis/8855/5 "2002-11-29T21:18:57Z")

</div>

I found the component by accident actually from a fla I got off the net awhile back, but I dont remember where i got it from. You can just copy the component from my sample fla and paste it onto your movie, just change the target names in the component’s parameters. Or you can just give your menu an instance name of “followClip” since my sample component is already targeting that instance name. Hope that 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:** [November 29, 2002, 9:49pm UTC](https://forum.kirupa.com/t/fmx-following-mouse-only-on-y-axis/8855/6 "2002-11-29T21:49:11Z")

</div>

belive me it did! i knew how to work it, i just wanted to know if i could down load it so it was in my components list. After using this i relized that i is easyer to just have it still, lol. Well its off to finish this up. I like the final design, and i am doing alot in DW as well. I cant wait to see the finished product! i will love it for a day, then hate it. lol, 😛

---

<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:** [November 29, 2002, 9:53pm UTC](https://forum.kirupa.com/t/fmx-following-mouse-only-on-y-axis/8855/7 "2002-11-29T21:53:37Z")

</div>

I remember reading from somewhere that components like this comes in a set with other useful components too, but I forgot the name of it. Oh well. :-\ Good luck.

---

<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:** [November 29, 2002, 9:57pm UTC](https://forum.kirupa.com/t/fmx-following-mouse-only-on-y-axis/8855/8 "2002-11-29T21:57:38Z")

</div>

Macromedia DRK got really cool set of components. For only $100 US.

---

<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:** [November 29, 2002, 10:01pm UTC](https://forum.kirupa.com/t/fmx-following-mouse-only-on-y-axis/8855/9 "2002-11-29T22:01:31Z")

</div>

Yeah!! thats the name of it!! I just couldnt recall what it was. The follow mouse component is just one of the many great components in that set. Thanks h88, I will definitely invest in that set after I gather 10,000 pennies. =)

---

<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:** [November 29, 2002, 10:04pm UTC](https://forum.kirupa.com/t/fmx-following-mouse-only-on-y-axis/8855/10 "2002-11-29T22:04:38Z")

</div>

Hmmm is it just being lazy when you have to download a file and use the component… or just copying and pasting this code on the object??

```auto
onClipEvent (load) {
_x = 0;
speed = 5;
}
onClipEvent (enterFrame) {
endY = _root._ymouse;
_y += (endY-_y)/speed;
}

```

Interesting thought…

---

<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:** [November 29, 2002, 10:08pm UTC](https://forum.kirupa.com/t/fmx-following-mouse-only-on-y-axis/8855/11 "2002-11-29T22:08:38Z")

</div>

I agree with u lost, components are needed for complicated jobs, not for something like easing. :-\

Well, DRK got many complicated ones, ie: DataGrid, Calender, …  
Developers better buying these components, it would save alot of time while coding.

---

<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:** [November 29, 2002, 10:08pm UTC](https://forum.kirupa.com/t/fmx-following-mouse-only-on-y-axis/8855/12 "2002-11-29T22:08:51Z")

</div>

You’re right Lost, it would be easier to just copying the code and pasting it, but I tend to do things the hard way. A habbit I need to kick to the curb. But thanks for the code though, I’m gonna save it to a text file for future references. =)

---

<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:** [November 29, 2002, 10:10pm UTC](https://forum.kirupa.com/t/fmx-following-mouse-only-on-y-axis/8855/13 "2002-11-29T22:10:06Z")

</div>

Or you could just visit the tutorial at kirupas site…lol.

I tend to do things the hard way as well, but with easing, I didn’t think there was a hard way…lol.

---

<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:** [November 30, 2002, 2:32am UTC](https://forum.kirupa.com/t/fmx-following-mouse-only-on-y-axis/8855/14 "2002-11-30T02:32:56Z")

</div>

i have memorized the easing thing lol, well the code from bit’s tut! its really simple! :P. I just didnt know how to minipulate it…
