1 Reply Latest reply on Nov 1, 2008 7:36 PM by Ned Murphy

    Rotation Problem... I need it to stay positive!!

    kurrle
      Hello everyone. I think what I have on my hands is a little trigonometry problem but I'm not sure because I never listened in math class.

      Here is the file I am referencing: http://pixel8media.com/help/index.html
      I'm trying to make the yellow arrow rotate from it's current position to the top position. Right now what I have going on is when the yellow arrow button is clicked it sets a variable to the rotation position that i want it to go to... that is the 330 number you see when the button is clicked. The other number shows the rotation of the arrows. The problem is that the rotation variable goes from 0-179 and then suddenly switches to a negative number and goes from -179 through -1 and this is throwing off the script that is rotating the arrows. Ahhhh!!!! hard to explain sorry. Here is a link to download the fla files: http://pixel8media.com/help/Archive.zip

      Can someone please help?

      Thanks in advance for your time
        • 1. Rotation Problem... I need it to stay positive!!
          Ned Murphy Adobe Community Professional & MVP
          Per the Flash documentation...

          ... _rotation... Specifies the rotation of the movie clip, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation.

          That's saying the the _rotation "position" is limited from -180 to 180. So what you think is 330 is actually -30.

          So you need to rethink things a bit for determining when the rotation has traveled 330 degrees from where it started.... the following will stop it after it's rotated that far

          if ( _parent.arrows._rotation + 30 < 1 ) {
          _parent.arrows._rotation = -30;
          gotoAndStop("off");
          }

          or to put the conditional in terms your code uses...

          if ( Math.abs(_parent.arrows._rotation - (_parent.RotateIt - 360)) < 1 ) {
          _parent.arrows._rotation = _parent.RotateIt - 360;
          gotoAndStop("off");
          }

          If you want the value that's switching between positive and negative to remain positive, then you need to use (sum) the delta values in each rotation increment until they add up to whatever you want RotateIt to be..