3 Replies Latest reply on May 14, 2011 3:14 PM by kglad

    HELP with setInterval problems!!! Lagging / Delaying problems!

    Gunto

      Hello!

      Well I am creating a project that involves music, and the flash should play a song and do something to it's beat...

      I have the song's BPM (beats per minute) data, and it's stored as a variable.

      I tried to animate something according to it using setInterval but I saw it doesn't sync perfectly.

      To show the problem I just put the number 1000 in the milliseconds part.


      function callback()

      {
           trace(getTimer());
           trace("interval called");
      }


      var intervalID;
      intervalID = setInterval( callback, 1000 );

       

      The output was:

       

      1017
      interval called
      2053
      interval called
      3077
      interval called
      4109
      interval called
      5128
      interval called

       

      and so on when each time it appears after approx. 1020-1040 milliseconds instead of exactly 1000

      Why isn't it precise?! How can I make it sync perfectly??... [My song requires 400 milliseconds at a time..]

      Is this command not rellevant?

       

      HELP! THANKS,

      Gunto