# \[fmx\] if mouse moves, telltarget

**URL:** <https://forum.kirupa.com/t/fmx-if-mouse-moves-telltarget/23226>\
**Category:** Uncategorized\
**Created:** [June 14, 2003, 11:34pm UTC](https://forum.kirupa.com/t/fmx-if-mouse-moves-telltarget/23226 "2003-06-14T23:34:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![luksy](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@luksy](https://forum.kirupa.com/u/luksy)\
**Post date:** [June 14, 2003, 11:34pm UTC](https://forum.kirupa.com/t/fmx-if-mouse-moves-telltarget/23226/1 "2003-06-14T23:34:18Z")

</div>

So, if mouse moves, tell target to play. If mouse doesn’t move tell target to stop. How?

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:** [June 14, 2003, 11:56pm UTC](https://forum.kirupa.com/t/fmx-if-mouse-moves-telltarget/23226/2 "2003-06-14T23:56:45Z")

</div>

try this:  
[AS]myMC.onMouseMove = function() {  
i++;  
this.gotoAndStop(i);  
};[/AS]

---

<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:** [June 15, 2003, 1:15am UTC](https://forum.kirupa.com/t/fmx-if-mouse-moves-telltarget/23226/3 "2003-06-15T01:15:35Z")

</div>

or maybe…

```auto
var xm = this._xmouse, ym = this._ymouse;
this.onEnterFrame = function() {
if (xm != (xm=this._xmouse) || ym != (ym=this._ymouse)) {
this.play();
} else {
this.stop();
}
};

```

---

<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:** [June 15, 2003, 2:36am UTC](https://forum.kirupa.com/t/fmx-if-mouse-moves-telltarget/23226/4 "2003-06-15T02:36:10Z")

</div>

what’s the difference?

---

<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:** [June 15, 2003, 2:43am UTC](https://forum.kirupa.com/t/fmx-if-mouse-moves-telltarget/23226/5 "2003-06-15T02:43:17Z")

</div>

good question. 😛

actually, there’s no real difference…  
when the mouse moves, the movieclip plays at the fps of the movie instead of playing accordingly to the mouse movement. 😉

---

<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:** [June 15, 2003, 2:47am UTC](https://forum.kirupa.com/t/fmx-if-mouse-moves-telltarget/23226/6 "2003-06-15T02:47:31Z")

</div>

oh, so it’s useful when loading external movies that have different frame rate then the main movie… interesting… but it wouldn’t make a difference when using MC’s that use the same frame rate as the main movie

---

<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:** [June 15, 2003, 3:03am UTC](https://forum.kirupa.com/t/fmx-if-mouse-moves-telltarget/23226/7 "2003-06-15T03:03:20Z")

</div>

just to add something to this thread…

i believe the correct usage of your script is:

```auto
myMovieClip.onMouseMove = function() {
i++;
this.gotoAndStop(i);
updateAfterEvent();
};

```

otherwise the animation will look choppy if you have a low frame rate.

and if you want to loop the animation:

```auto
myMovieClip.onMouseMove = function() {
this.gotoAndStop(1+(i++)%this._totalframes);
updateAfterEvent();
};

```
