3 Replies Latest reply on Feb 1, 2010 9:20 AM by Ned Murphy

    Clock hand rotation issue?

    DigiFront

      Hey there!

       

      I have some code that I have pulled from various sources and thought it was straight forward... but it seems to have a simple issue. As the hand rotates around with the script, but it gets to 180 degrees and then resets itself into the "-" value?... to times down from -180 to 0.... I need the time to run as a 10min timer?....

       

      Any suggestions!?

       

      Main:

       

      stop();

       

      _root.stopBtn._visible = false;
      _root.stopTxt._visible = false;

       

      myTimer = setInterval(play, 1000);

       

      function wait() {
          mySeconds++;
          _root.mySecondHand._rotation += 1;
          _root.myMinuteHand._rotation += 30;
          _root.myMilliSeconds._rotation += 1;

       

          if (mySecondHand._rotation == 3600) {
              _root.clearInterval(myTimer);
              }

       

      }

       

      Button:

      on (release) {
          clearInterval(myTimer);
          myTimer = setInterval(wait, 101);
      }

        • 1. Re: Clock hand rotation issue?
          Ned Murphy Adobe Community Professional & MVP

          You could use a variable to keep track of the growing rotation value rather than the _rotation value itself.  Each time you change the _rotation, you change that variable by the same amont, and use that variable for your conditional test rather than the actual rotation value.

           

          stop();

           

          _root.stopBtn._visible = false;
          _root.stopTxt._visible = false;

           

          myTimer = setInterval(play, 1000);

           

          var secondCount = 0;

           

          function wait() {
              mySeconds++;
              _root.mySecondHand._rotation += 1;

               secondCount += 1;
              _root.myMinuteHand._rotation += 30; // one fast minute hand
              _root.myMilliSeconds._rotation += 1; // one slow msec hand

           

              if (secondCount == 3600) {
                  _root.clearInterval(myTimer);
                  }

           

          }

           

          Button:

          on (release) {
              clearInterval(myTimer);
              myTimer = setInterval(wait, 101);
          }

          • 2. Re: Clock hand rotation issue?
            DigiFront Level 1

            Thanks Ned!

             

            Thats working nicely

            • 3. Re: Clock hand rotation issue?
              Ned Murphy Adobe Community Professional & MVP

              You're welcome