# \[FMX\] movent with mouse

**URL:** https://forum.kirupa.com/t/fmx-movent-with-mouse/106596
**Category:** Uncategorized
**Created:** [April 7, 2004, 6:59am UTC](https://forum.kirupa.com/t/fmx-movent-with-mouse/106596 "2004-04-07T06:59:10Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![dboers](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@dboers](https://forum.kirupa.com/u/dboers)
#### Post date: [April 7, 2004, 6:59am UTC](https://forum.kirupa.com/t/fmx-movent-with-mouse/106596/1 "2004-04-07T06:59:10Z")

</div>

Hello,

I have a white square(mc) on my stage. In the top left corner of that square is a little arrow. I want that arrow to move along the \_y axis when the mouse is moving on the square. So i want the square to move along with the mouse. I like the movement to be easing. Is there somebody to help me?

---

<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: [April 7, 2004, 8:14am UTC](https://forum.kirupa.com/t/fmx-movent-with-mouse/106596/2 "2004-04-07T08:14:29Z")

</div>

```auto
MovieClip.prototype.easeY = function(y){
 this.onEnterFrame = function(){
 this._y = y-(y-this._y)/1.2
 if(this._y > y-1 && this._y < y+1){
 this._y = y;
 delete this.onEnterFrame;
 }
 }
 }
 _root.onMouseMove = function(){
 square.easeY(_root._ymouse);
 }

```

---

<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: [April 7, 2004, 8:29am UTC](https://forum.kirupa.com/t/fmx-movent-with-mouse/106596/3 "2004-04-07T08:29:15Z")

</div>

Hi Voetsjoeba,

Thank you for your fast reaction. The square is moving, but that’s not what I needed. As I told before. On the square is an little arrow, which I want to move with the mouse. But only when the mouse is on the square. So the arrow have to stay on the square.

---

<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: [April 7, 2004, 9:37am UTC](https://forum.kirupa.com/t/fmx-movent-with-mouse/106596/4 "2004-04-07T09:37:07Z")

</div>

Ah ok, your first post confused me a bit, but when reading “So i want the square to move along with the mouse”, I thought that it was the square that eventually had to move with the mouse, not the arrow. Anyway. This is what you could do:

```auto

MovieClip.prototype.easeY = function(y){
this.onEnterFrame = function(){
this._y = y-(y-this._y)/1.2
if(this._y > y-1 && this._y < y+1){
this._y = y;
delete this.onEnterFrame;
}
}
}
_root.onMouseMove = function(){
if(this.square.hitTest(this._xmouse,this._ymouse)){
this.square.arrow.easeY(_root._ymouse);
}
}

```

---

<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: [April 7, 2004, 11:01am UTC](https://forum.kirupa.com/t/fmx-movent-with-mouse/106596/5 "2004-04-07T11:01:40Z")

</div>

Hi Voetsjoeba,

It works perfect :thumb: Thank jou 😉

---

<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: [April 7, 2004, 11:35am UTC](https://forum.kirupa.com/t/fmx-movent-with-mouse/106596/6 "2004-04-07T11:35:03Z")

</div>

Geen probleem 😉
