Using _xmouse to display a certain frame of a MC

I have a MC of 38 frames. I want a different frame to display depending on the x position of the mouse so that the user will play the MC by moving their mouse.

Any ideas?

:trout: I should be able to do this, but my brain has a huge mental block and maths is the last thing that want to stick in my poor ol’ brain. (Been concentrating too much on 3D hehehe)

let’s see…

onMouseMove = function() {
num = (mc._totalframes/Stage.width)*_xmouse;
mc.gotoAndStop(num);
}

does that work? haven’t tested or anything :slight_smile:

dankie, but don’t seem to work. maybe i’m missing something.
i’ll have to continue scratching my head :slight_smile:

oh alright… how about this then :slight_smile:

this.onMouseMove = function() {
	var num = Math.round((mc._totalframes/550)*this._xmouse);
	mc.gotoAndStop(num);
	updateAfterEvent();
}

blank? :h:
hehehe

ok, i got this one to work…

onClipEvent (enterFrame) {
xm = parseInt(_root._xmouse);
mcf = parseInt(_root.head._totalframes);
sw = 600;
num = Math.round(xm*(mcf/sw));
_root.head.gotoAndStop(num);
}

just need to refine it a little more. i tried sw = Stage.width, but it didn’t work that well. gave me other calculations…

thanx for the help mediamonkey :slight_smile: