dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Mouse follower

  1. #1
    Member
    Join Date
    Jan 2005
    Location
    United Kingdom
    Posts
    97

    Mouse follower

    I am making a flash file that contains a simple circle as a symbol which contains a small dash at the 12 o'clock position. What I want is for the circle to rotate so that the dash always points towards the user's cursor. Is this possible? If so, could anyone help by telling me what ActionScript I need to write!

    Thanks!

  2. #2
    Senior Member Cass101's Avatar
    Join Date
    Dec 2004
    Posts
    131
    something like this?

    Code:
    onClipEvent (enterFrame) {
            myRadians = Math.atan2(_root._ymouse-this._y, _root._xmouse-this._x);
            myDegrees = Math.round((myRadians*180/Math.PI));
            this._rotation = myDegrees+90;
    }
    Your circle with the dash in it will need to be a movie clip, and you simply add this code to it.
    Last edited by Cass101; 03-02-2005 at 04:02 PM.

  3. #3
    Member
    Join Date
    Jan 2005
    Posts
    60
    Also, make sure the registration point is in the middle of the clock, if you didn't already know that.

    PS: I'm pretty sure it has to be... because it rotates around the registration point.

  4. #4
    Member
    Join Date
    Jan 2005
    Location
    United Kingdom
    Posts
    97
    Thanks! That worked exactly as I wanted.

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