1 Reply Latest reply on Oct 15, 2013 6:54 AM by skotch99

    Possible to pause or delay in a loop?

    skotch99 Level 1

      Hi - wondering if there is a way to pause inside a loop.  I am away that jQuery has a delay() function but i can't seem to get it to work.

       

      was thinking something like:

       

      blob = "This is a test of the emergency broadcast system";

      for (i=0; i<blob.length; i++)

      {

      sym.$("Text").delay(300).html(blob[i]);

      }

       

       

      any ideas?

       

      thanks!!

        • 1. Re: Possible to pause or delay in a loop?
          skotch99 Level 1

          got it - just in case others have a similar question - this worked:

           

           

          var i = 0;

          function nextFrame() {

              if(i < blob.length) {

                  {sym.$("Text").html(a+blob[i])

                  a=a+blob[i];

                  }

                  i++;

                  // Continue the loop in 50ms

                  setTimeout(nextFrame, 50);

              }

          }