4 Replies Latest reply on Apr 16, 2011 4:56 AM by Ned Murphy

    Newbie question: What's the best way to create a fade? Action script or alpha channel?

    lhwohl Level 1

      I have figured out two ways to get my images (movie clips or just objects) to fade on the timeline. The first is by adding the "Fade in a movie clip" code snippet. The second is by creating a motion tween for a non-moving movie clip just for adjusting the alpha setting between 0 and 100%. In both cases, I've created a duplicate of the prior frame and placed it below, which seems like a bulky way to do this, but nothing else comes to mind. Seems easier to adjust the speed of the fade in by changing the number in the action script, and I can make those adjustments at any time once the script is created. On the other hand, if I know how many frames I want the transition to last, I can easily create the correct alpha fade. Is there another better way to do this?

       

      Thanks!

        • 1. Re: Newbie question: What's the best way to create a fade? Action script or alpha channel?
          Ned Murphy Adobe Community Professional & MVP

          I am not familiar with the code snippet you mention, so seeing the code could help.  Generally actionscript tweening is more flexible and probably performs better than anything you might try with a timeline tween.  If the code snippet involves using the Tween class, the Tween class allows you to specify whether the tween duration is measured in time or in frames.

           

          And most folks who deal in actionscript tweening generally recommend using third party tweening engines such as TweenLite, TweenMax, Tweener, ?etc, explaining that they are more flexible and outperform the built in Tween class.

          1 person found this helpful
          • 2. Re: Newbie question: What's the best way to create a fade? Action script or alpha channel?
            lhwohl Level 1

            In terms of the code, this is what gets generated when I select the snippet:

             

            /* Fade In Movie Clip

            Fades in the symbol instance by increasing its alpha property within an ENTER_FRAME event until it is fully visible.

            Instructions:

            1. To change the speed at which the symbol instance fades in, change the 0.01 value below (valid values are in the range 0.0 - 1.0). Higher values cause faster fade in.

            2. The '+=' operator is a shortcut to typing 'movieClip_2.alpha = movieClip_2.alpha + 0.1'.

            3. Because the animation uses an ENTER_FRAME event, it progresses only when the playhead moves to a new frame, and the speed of the animation is also affected by the frame rate of the FLA file.

            */

             

            movieClip_2.addEventListener(Event.ENTER_FRAME, fl_FadeSymbolIn_10);

            movieClip_2.alpha = 0;

             

            function fl_FadeSymbolIn_10(event:Event)

            {

            movieClip_2.alpha += 0.05;

            if(movieClip_2.alpha >= 1)

            {

            movieClip_2.removeEventListener(Event.ENTER_FRAME, fl_FadeSymbolIn_10);

            }

            }

            :

             

            Works fine and I can easily adjust the speed of the fade. But then the fade created by creating a tween in the timeline works fine as well. By "performs better," do you mean smoother? More reliably? Something else? No idea what the advantage is with a third party tweening engine -- what it means in practical terms to outperform the built in tween class (honestly, I'm not even sure what a "tween class" is) -- or why you'd need something like that. I'm just too new at this and I'm picking up what I can through tutorials until I can schedule some real one-on-one training. I really appreciate any light you can shed.

            • 3. Re: Newbie question: What's the best way to create a fade? Action script or alpha channel?
              Darshan Rane Level 3

              Why dont u try Tweenlite Engine

               

              http://www.greensock.com/tweenlite/

               

              Check Interactive Demo - Tweening basics part will give u the required code.

               

              --

              http://www.darshanrane.com

              • 4. Re: Newbie question: What's the best way to create a fade? Action script or alpha channel?
                Ned Murphy Adobe Community Professional & MVP

                That code uses the ENTER_FRAME event to manage the timing of it, which is essentially identicial to having a timeline tween since it will operate at the frame rate of the file.  The Tween class allows you to specify things in terms of time rather than frames (or frames as well).

                 

                Yes, you can get much smoother results usng actionscript tweening and if you plan to get involved with Flash as a design tool for a career, then you will eventually come to learn that using tweening via actionscript is quite useful.

                 

                If you want to learn more about the Tween class, just look it up in the help documents or Google "AS3 Tween tutorial".  Here's a link to one result from such a search...

                 

                http://www.republicofcode.com/tutorials/flash/as3tweenclass/

                 

                And I will add that using an ENTER_FRAME coding approach similar to the snippet you showed is also useful at times.

                1 person found this helpful