PDA

View Full Version : [fmx] if mouse moves, telltarget...



luksy
June 14th, 2003, 07:34 PM
So, if mouse moves, tell target to play. If mouse doesn't move tell target to stop. How?

Thanks.

zylum
June 14th, 2003, 07:56 PM
try this:
myMC.onMouseMove = function() {
i++;
this.gotoAndStop(i);
};

kode
June 14th, 2003, 09:15 PM
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();
}
};

zylum
June 14th, 2003, 10:36 PM
what's the difference?

kode
June 14th, 2003, 10:43 PM
good question. :P

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. ;)

zylum
June 14th, 2003, 10:47 PM
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

kode
June 14th, 2003, 11:03 PM
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();
};