# Follower?

**URL:** <https://forum.kirupa.com/t/follower/32126>\
**Category:** flash\
**Created:** [October 1, 2003, 9:19pm UTC](https://forum.kirupa.com/t/follower/32126 "2003-10-01T21:19:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![flash2004](https://avatars.discourse-cdn.com/v4/letter/f/4da419/32.png) [@flash2004](https://forum.kirupa.com/u/flash2004)\
**Post date:** [October 1, 2003, 9:19pm UTC](https://forum.kirupa.com/t/follower/32126/1 "2003-10-01T21:19:22Z")

</div>

Im attempting to create a mouse “follower” that follows my mouse across an x axis at the top of my flash document.

I have no idea where to start. Any suggestions?

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:** [October 24, 2003, 8:36pm UTC](https://forum.kirupa.com/t/follower/32126/2 "2003-10-24T20:36:07Z")

</div>

hey how would i do this if i wanted it to follow both x and y? like following your mouse. I tried the following:

[AS]onClipEvent (enterFrame) {  
speed += (this.\_parent.\_xmouse-this.\_x)\*acceleration;  
speed \*= friction;  
this.\_x += speed;  
speed += (this.\_parent.\_ymouse-this.\_y)\*acceleration;  
speed \*= friction;  
this.\_y += speed;  
}[/AS]

it kind of seems weird but on the right track.

any suggestions?

---

<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:** [October 24, 2003, 8:40pm UTC](https://forum.kirupa.com/t/follower/32126/3 "2003-10-24T20:40:42Z")

</div>

Define a variable for each axis! 😉

```auto
onClipEvent (load) {
var acceleration = .4;
var friction = .6;
var xspeed = 0;
var yspeed = 0;
}
onClipEvent (enterFrame) {
xspeed += (this._parent._xmouse-this._x)*acceleration;
xspeed *= friction;
this._x += xspeed;
yspeed += (this._parent._ymouse-this._y)*acceleration;
yspeed *= friction;
this._y += yspeed;
}

```

---

<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:** [October 24, 2003, 9:21pm UTC](https://forum.kirupa.com/t/follower/32126/4 "2003-10-24T21:21:40Z")

</div>

thanks hehe 🙂

---

<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:** [October 24, 2003, 9:36pm UTC](https://forum.kirupa.com/t/follower/32126/5 "2003-10-24T21:36:01Z")

</div>

You’re welcome. :beam:
