3 Replies Latest reply on Apr 15, 2009 6:20 AM by Ned Murphy

    How to fade in MCs with ‘new Tween’ & ‘onMotionFinished’ in a loop?

    absurd29

      Using 'new Tween' & 'onMotionFinished' I’m fading in several movie clips 1 after another. The number will vary in different movies.

      Can anyone show me how to do this in a loop instead of having to hard code it for each individual movie clip as in the following code?

       

      //hide movie clips to start with:

      var numberOfSentences:Number = 4;

      function hideSentences() {

                  for (var i:Number = 1; i<=numberOfSentences; i++) {

                              var speech:String = "speech"+i;

                              this[speech]._alpha = 0;

                              this[speech]._accProps.silent = true;

                  }

      }

      hideSentences();

       

       

      //now fade Movie Clips in 1 at a time. How can I loop this section?:

      var showText1:Tween = new Tween(speech1, "_alpha", Strong.easeIn, 0, 100, 1, true);

      showText1.onMotionFinished = function() {

                  delete speech1._accProps.silent;

                  var showText2:Tween = new Tween(speech2, "_alpha", Strong.easeIn, 0, 100, 2, true);

       

                  showText2.onMotionFinished = function() {

                              delete speech2._accProps.silent;

                              new Tween(speech3, "_alpha", Strong.easeIn, 0, 100, 2, true);

       

                              showText3.onMotionFinished = function() {

                                          delete speech3._accProps.silent;

                              };

                  };

      };

       

      Thanks for any help offered :-)