1 Reply Latest reply on Jul 19, 2007 8:45 AM by SymTsb

    slowing down actionscript

    chopTheWood Level 1
      Here is a script that moves a pointer horizontally along a bar. Positioned horizontally along the bar is a series of images. The pointer points to the image that the cursor moves over. It works but the pointer seems to jump from one position to the next rather than "slide" with a smooth motion and ease into position. Apparently Actionscript doesn't wait for the object to move just 1 pixel before executing the next loop in the While statement. I am making a Flash 7 file, any suggestions:

      function slidePointer(newLoc) {
      var newLoc:Number;
      var currentLoc:Number = getProperty("pointer", _x);
      while (++currentLoc<newLoc) {
      setProperty("pointer", _x, currentLoc);
      }
      while (--currentLoc>newLoc) {
      setProperty("pointer", _x, currentLoc);
      }
      }
        • 1. Re: slowing down actionscript
          SymTsb Level 2
          use setInterval to make incremental movements between the two points rather than using the while statement. the screen won't update until the loop is finished if you are using while but if you use setInterval, it will update after each iteration of the timer.