A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Rotation follow cursor help

  1. #1
    Senior Member
    Join Date
    Feb 2003
    Posts
    129

    Rotation follow cursor help

    Hello,

    I've put together some code to allow the user to rotate a clock hand around the clock by dragging it round. My code isn't working and I was wondering if anyone could take a look at it and see what I'm doing wrong.

    Code:
    onClipEvent (mouseDown) {
    	if (this.hitTest(_root._xmouse, _root._ymouse)) {
    		 arrowDrag = true;
    	}
    }
    
    onClipEvent(mouseMove) {
    	if (arrowDrag == true) {
    		var coordy1 : Number = _ymouse - this._y;
    		var coordx1 : Number  = _xmouse - this._x;
    		var angleRadians1 : Number  = Math.atan2(coordy1,coordx1);
    		var angleDegrees1 : Number  = angleRadians1 * 180 / Math.PI;
    		this.rotation = angleDegrees1;
    	}
    }
    
    onClipEvent(mouseUp) {
    	arrowDrag = false;
    }
    Thanks.

  2. #2
    Senior Member
    Join Date
    Feb 2003
    Posts
    129
    Anyone have any ideas? I have a feeling the code I used for the calculation of the mouse position and the rotation of the clock hand are in AS1 whereas the rest is AS2, perhaps. But I'm not sure to be honest because I've only ever had a basic grasp of AS2. Can anyone spot where I'm going wrong?

  3. #3
    Senior Member dudeqwerty's Avatar
    Join Date
    Mar 2005
    Location
    Bosnia
    Posts
    1,626
    I've made you an example .fla on how to achieve what you want.
    Attached Files Attached Files
    New sig soon

  4. #4
    Senior Member
    Join Date
    Feb 2003
    Posts
    129
    Thank you for your help, dudeqwerty.

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