2 Replies Latest reply on Jul 4, 2006 9:34 AM by kglad

    Delay timer

    JstMrd
      Hello,

      Is there a simple way to generate a delay within a function. I am trying to create a typewriter simulation of text, but require a delay when the next letter is chosen. I have tried using a standard for loop, which should technically work. But it creates one big delay then displays the result.

      thanks
        • 1. Re: Delay timer
          Level 7
          Hi!

          You might want to check out the Write on text effect tutorial at
          http://www.gotoandlearn.com/

          You might also want to check out the onEnterFrame function (for movieclips)
          or setInterval function.Or you could trigger it at the end of some sound you
          play when a text pops up.

          /Jensen/

          "JstMrd" <webforumsuser@macromedia.com> wrote in message
          news:e8dj72$cf6$1@forums.macromedia.com...
          > Hello,
          >
          > Is there a simple way to generate a delay within a function. I am trying
          > to
          > create a typewriter simulation of text, but require a delay when the next
          > letter is chosen. I have tried using a standard for loop, which should
          > technically work. But it creates one big delay then displays the result.
          >
          > thanks
          >
          > stop();
          > // outThere = dynamic text box variable
          >
          > var sampleText:String = "Hello There World";
          > var totalLetters:Number = (sampleText.length);
          > //trace (totalLetters);
          >
          > for (var letterCount:Number=0;letterCount<totalLetters+1;letterCount++) {
          > outThere = sampleText.substr(0,letterCount);
          > for (var delayCount:Number=0;delayCount<5000;delayCount++) {
          > }
          > }
          >


          • 2. Re: Delay timer
            kglad Adobe Community Professional & MVP
            for-loops and while-loops executed from beginning to end before anything is updated on-stage and no code other code is executed once these loops start (until they finish).

            that's why they can't be used for on-stage animation like a type-writer effect. as mentioned by jensen, use an onEnterFrame handler, setInterval() function or you can use a frame-loop.