A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Rotation

  1. #1
    Senior Member
    Join Date
    Dec 2000
    Posts
    164
    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

  2. #2
    Senior Member
    Join Date
    Jun 2000
    Posts
    911
    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.

  3. #3
    Senior Member
    Join Date
    Dec 2000
    Posts
    164

    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center