1 Reply Latest reply on May 19, 2009 6:06 AM by kglad

    How to stop a recursive loop

    absurd29

      I have a recursive loop to fade in several movie clips one after another (see script below), it works fine & the flash sits in an html page. However, when I navigate between this & other html pages – sometimes the recursion is still happening on returning to this page & at the same time it starts again so it looks like items are fading in in a completely random manner.

      How do I stop/reset the recursive loop on entering the page again?

      Thanks in advance for any suggestions.

       

       

      function revealSentences(num:Number) {

                  var showText:Tween = new Tween(this["speech"+num], "_alpha", Strong.easeIn, 0, 100, 2, true);

                  showText.onMotionFinished = function() {

                              _root["speech"+num].sentences_txt.text = _root.textItems[num];

                              delete this["speech"+num]._accProps.silent;

                              if (num<textItems.length) {

                                          trace("num: "+num);

                                          revealSentences(num+1);

                              }

                  };

      }

      revealSentences(0);