AS - movement after mouse (x and rotate)


I want to have a ball, that will follow the mouse a little… The ball will only follow the x way but i cant get it working. I have this code on the frame:

_root.ball(controlX, 176.8)

I have no idea if this one is right in anyway… but no error atleast.
The ball have the instance name “ball”.

I also want that the ball will rotate how longer it is at the x way, so it will rotate as much as _xmouse.
Can someone change the code so it will work?

try this:

ball.onMouseMove = function() {
this._x = _xmouse/2; //2 is how much you want it to follow by
this._rotation = _xmouse;

try that, lemme know how it works.


Thanks ! :smiley:

it works great, i only needed to change one thing on the mc :slight_smile:

This is my code now

ball.onMouseMove = function() {
this._x = _xmouse/4;
this._rotation = 1.2*_xmouse;

but… the ball start on x=0… can i do anything to change that? And is it hard to add so the ball smoothly will stop?

right before the first line do this:

ball._x = 30; //30 is your x position.

if you want to have it on a certain y, put this, as well as the above:

ball._y = 30; //30 is your y position.

hope that helps ya!


hm… it dont work :frowning: It is on X=0 yet :frowning:

i got it working :smiley: :smiley: :smiley:

i had to do this:

this._x = 243.8+_xmouse/4;

now it works :smiley:

But can someone tell me how to do it so it will smoothly stop ?