2 Replies Latest reply on Jul 6, 2013 3:54 PM by Charine -FB buggoop

    Fade in of movie clips

    Charine -FB buggoop Level 1

      Hi,

      I have a bunch of movie clips in an array. This array exist in a loop run by a timer.

       

      Every .5 of a second one of the movie clips in the array is paced on the stage. Now I need to fade each in gradually and also make them move accross the stage.

       

      I've used code snippets to try to write a fade in function, but the problem is that the whole bunch fades in at the same rate (For example, the first movie clip that apeared on stage would have the same alpha as the sixth after three seconds)

       

      How do I change the code below so that each movie clip could fade in accourding to the time it (individually as opposed to the whole array) would start fading in only when it is placed on the stage.

       

      Here is my code so far:

       

      private var  lettersL1:Array = [a,a,f,f,f,g,h,i,i,n,n,n,o,o,o,o,s,s,t,t,t];

       

      lettersL1[index].addEventListener(Event.ENTER_FRAME, fl_FadeSymbolIn);

                 

                      function fl_FadeSymbolIn(event:Event)

                          {

                              lettersL1[index].alpha += 0.01;  //lettersL1 is the name of the array

                              if(lettersL1[index].alpha >= 1)

                              {

                               lettersL1[index].removeEventListener(Event.ENTER_FRAME, fl_FadeSymbolIn);

                               }

                          }

                         

                     addChild(lettersL1[index]);

       

       

      Thanks

      Charine

        • 1. Re: Fade in of movie clips
          Ned Murphy Adobe Community Professional & MVP

          Without seeing the rest of the code it is a but difficult to track some aspects down.  Why that array repeats objects is one issue I can't get my head around.  I don't know if the ENTER_FRAME is out of control with the way you have it implemented either.  That the function is using the index value is another since the index value will be changing with your loop, not with each object in it.

           

          I suggest you try a different approach and look into using the Tween class to fade and move the objects.  You can assign a tween for each and you don't need to have all kinds of ENTER_FRAME listeners getting assigned

          • 2. Re: Fade in of movie clips
            Charine -FB buggoop Level 1

            Ok thanks Ned,

             

            Whooo-hoo I did the tween on the movie clip and it works!

             

            Was able to do motion and alpha with much better control and minimal additional file size.

             

             

            Greatly appreciated!

             

            Charine