dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Rotation help needed

  1. #1
    Senior Member
    Join Date
    May 2003
    Posts
    160

    Rotation help needed

    hi all, i have this sample movie where an arrow follows the mouse movement on screen. what i'd like to happen to to not have the arrow able to rotate 360 degrees, say only 90 degrees for example.

    anyone, please??? thanks.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    Los Angeles
    Posts
    86
    do this at the root level:
    (you could just use numbers in the mc script, but this makes it easier to adjust quickly)

    min_rotate = -90;
    max_rotate = 90;


    then change your mc script to:

    onClipEvent(enterFrame)
    {

    var dy = _root._ymouse - this._y;
    var dx = _root._xmouse - this._x;
    _root.rotate_value = Math.atan2(dy,dx)*180/Math.PI;
    if((_root.rotate_value>_root.min_rotate)and(_root. rotate_value<_root.max_rotate)){
    this.arrow._rotation = _root.rotate_value;
    _root.rotate_tx = Math.round(_root.rotate_value);

    }


    //the following 2 statements set the arrow to min and max if you move the mouse out of range
    if(_root.rotate_value<_root.min_rotate){
    this.arrow._rotation = _root.min_rotate;
    }
    if(_root.rotate_value>_root.max_rotate){
    this.arrow._rotation = _root.max_rotate;
    }
    }

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