6 Replies Latest reply on May 13, 2008 6:46 PM by kglad

    Looping Text Field Delay

    cfords
      Hi all - Noob here again. Using Flash 8/AS 2.0. I have a dynamic text field movie clip that has a typewriter effect and am using the same window to display (3) separate sets of text that I want to loop. I am trying to incorporate a delay of some kind to keep the text on screen for about 3 seconds before the screen changes. The code spans the first (3) frames of the movie clip and is as attached. The only problem is that I can't seems to eek out a workable delay. I have tried setInterval/clearInterval all over the place but I am coding it wrong and/or in the wrong place. What I want is for the text to stay on the screen for about (3) secs once the typewriter effect is complete before it loads the next set of text. Everything works reliably and smoothly, it just runs too fast to have time to read each screen. Any clues? This is a huge step for my total noobness. Thanks for reading this mess, I hope everything is as clear as mud :)

        • 1. Re: Looping Text Field Delay
          kglad Adobe Community Professional & MVP
          remove your gotoAndPlay(2) in your case branches and replace with setTimeout(gotoF,delay), where delay is the delay you want between text strings (in milliseconds) and define:

          function gotoF(){
          _root.gotoAndPlay(2);
          }
          • 2. Re: Looping Text Field Delay
            cfords Level 1
            setTimeout! I need to *cough* study the help files more *cough*. Wow, pretty simple, altho I suspected it had to be in this case. Thanks for spelling out a simple usage routine for me, I do appreciate it. I will try this out in a bit and post the results. Seems as if things have changed a bit since VB 3.0 haha...
            • 3. Re: Looping Text Field Delay
              kglad Adobe Community Professional & MVP
              you're welcome.

              p.s. setTimeout() is just like setInterval() except it only calls the function once and therefore does not need to be cleared.
              • 4. Re: Looping Text Field Delay
                cfords Level 1
                setTimeout() sounds like what I need. However, I tried replacing "gotoAndPlay(2);" in my case statements with "setTimeout(gotoF,3000)" (minus the quotes of course) and declaring:

                function gotoF(){
                _root.gotoAndPlay(2);
                }

                in frame 1, and all it is doing is repeating the first line of text over and over. It is acting as if the code setTimeout(gotoF,3000) in the case statements isn't there. ie, I get the same interpretation if I comment it out as well. Perhaps I am not declaring the function correctly or in the correct place. I am missing something, that cannot be denied. It is true that I have done ZERO programming outside of HTML since VB 3.0. I think it is a clear understanding of the way flash loads that may be giving me troubles. I should add that I have several elements on the stage, this text field is running on it's own timeline separate from the main timeline. This shouldn't matter as far as I know. Arrrgh.
                • 5. Re: Looping Text Field Delay
                  cfords Level 1
                  Ok, flash it is seeing the setTimeout() in the case statements, it is just behaving strangely. I added a trace statement to see what the deal was. The setTimeout() is running after it is called the first time, then the event is getting stuck in a loop. The first text string is displaying over and over. It is like the setTimeout() is running in the background but not effecting the text at all. It is being called but doing some internal self-serving loop. Hmmmm...So, long story short, after the first text string displays and the (loop>charcount) is satisfied, CASE 1 runs the setTimeout() and everything in the text field loops for all eternity without ever progressing to the second line of text. I re-attached the current relevant code and will keep reading in the meantime. WOAH.
                  • 6. Re: Looping Text Field Delay
                    kglad Adobe Community Professional & MVP
                    i don't see a stop() on frame 3. so, you're playhead is going to return to frame 1 immediately after your frame 3 code executes.