[fmx] if mouse moves, telltarget

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

Thanks.

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

or maybe…

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

what’s the difference?

good question. :stuck_out_tongue:

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. :wink:

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

just to add something to this thread…

i believe the correct usage of your script is:

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:

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