johnnyboy
01-18-2006, 09:16 PM
Hi there,
I found a very simple script to detect the angle of the mouse:
onClipEvent (mouseMove) {
adjside =_root. _xmouse-_root.origin._x;
oppside = -1*(_root._ymouse-_root.origin._y);
angle = Math.atan2(oppside, adjside); // in radians
angle = Math.round(angle/Math.PI*180); // convert to degrees
_root.compass._rotation = -1*(angle);
}
Problem is, I want it to be a part of a function that I wrote, but it wont work... the angle variable comes out "NAN" instead of showing the angle...?
function setCursor (){
mouse_mc._x = _xmouse;
mouse_mc._y = _ymouse;
if (thePress == true) {
xdir = _xmouse; // activates the rotation via direction of mouse
//
adjside = _root._xmouse-_root.origin._x;
oppside = -1*(_root._ymouse-_root.origin._y);
angle = Math.atan2(oppside, adjside); // in radians
angle = Math.round(angle/Math.PI*180); // convert to degrees
_root.compass._rotation = -1*(angle);
}
updateAfterEvent ();
}
Any ideas here?
I found a very simple script to detect the angle of the mouse:
onClipEvent (mouseMove) {
adjside =_root. _xmouse-_root.origin._x;
oppside = -1*(_root._ymouse-_root.origin._y);
angle = Math.atan2(oppside, adjside); // in radians
angle = Math.round(angle/Math.PI*180); // convert to degrees
_root.compass._rotation = -1*(angle);
}
Problem is, I want it to be a part of a function that I wrote, but it wont work... the angle variable comes out "NAN" instead of showing the angle...?
function setCursor (){
mouse_mc._x = _xmouse;
mouse_mc._y = _ymouse;
if (thePress == true) {
xdir = _xmouse; // activates the rotation via direction of mouse
//
adjside = _root._xmouse-_root.origin._x;
oppside = -1*(_root._ymouse-_root.origin._y);
angle = Math.atan2(oppside, adjside); // in radians
angle = Math.round(angle/Math.PI*180); // convert to degrees
_root.compass._rotation = -1*(angle);
}
updateAfterEvent ();
}
Any ideas here?