Link to home
Start Free TrialLog in
Avatar of Brian Lin
Brian LinFlag for United States of America

asked on

Eye movie clip " watching " the mouse arrow scripting

Hi,

I want to create a eye to see the mouse arrow no matter where the mouse arrow moves. I sort have an example but it does not working right. I wonder if any experts can solve the problem ? I wish the eye can move smoothly. Also, The file must be the same and can only modify the code....

File: http://rapidshare.com/files/97180417/testing.zip.html

Thanks a lot

- B -
Avatar of Aneesh Chopra
Aneesh Chopra
Flag of India image

here is the fix:

replace following complete code:

//eyeball teack mouse
this.onEnterFrame = function()
{
      xdist = _root._xmouse+_x;
      ydist = _root._ymouse+_y;
      _rotation = Math.atan2(ydist, xdist)*180/Math.PI+90;
};




replace it with following:

// updated eyeball teack mouse
var point = {x:this._x, y:this._y};
this.localToGlobal(point);

this.onMouseMove = function()
{
      Xm = _root._xmouse;
      Ym = _root._ymouse;
      Xdiff = Xm-point.x;
      Ydiff = Ym-point.y;
      radAngle = Math.atan2(Ydiff, Xdiff);
      this._rotation = 90+radAngle*360/(2*Math.PI);
      updateAfterEvent();
};
I have used "onMouseMove" instead of "onEnterFrame", because "onMouseMove" uses less system resources as compare to "onEnterFrame"
its on personal choice, you can change "onMouseMove" to "onEnterFrame"

output will remain same.
Avatar of Brian Lin

ASKER

Hi, thanks for the code. I wonder if it is possible to make eye rolls like normal eye. The current eye is just rotate around.... Thanks :)
ASKER CERTIFIED SOLUTION
Avatar of Aneesh Chopra
Aneesh Chopra
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial