-
hey, i remember lookin at a post a while back and someone had asked how to rotate somethign according to the mouse postion. i believe it was SubKloda who posted a beatiful response that needed only 1 line of actionscript. something like:
onClipEvent (mouseMove) {
this._rotation = Math.atan(_xmouse/_ymouse)*(180/Math.PI)
}
or along those lines atleast. can anyone give me a lil help??
thx!
~MOose
-
I think something like this would do it:
Code:
onClipEvent (mouseMove) {
this._rotation = Math.atan2 (_root._ymouse, _root._xmouse) * (180/Math.PI);
}
The "atan2" function does all the quadrant checking for you since "atan" (by definition) only returns principal values (from -pi/2 to pi/2).
Good luck.
-
wonderful!
i didnt know what the atan2 was for, thx for the help
btw, this is the one that works:
onClipEvent (mouseMove) {
this._rotation = Math.atan2 (_root._ymouse-this._y, _root._xmouse-this._x)*(180/Math.PI)
}
btw, how do you get the code to be in grey and centered in the post with diff text properties etc.. ??
cheers
~MOose
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|