11.3. Fading Movie Clip Instances In and Out

Problem

You want to create an effect in which a movie clip appears to fade in or out of your movie.

Solution

Use a motion tween between an instance of the movie clip at 100% alpha to an instance of the movie clip at 0% alpha, to create a fade-out effect—or the reverse to fade-in.

Alternatively, you can use an interval function (or an onEnterFrame( )) event handler method to increment or decrement a movie clip’s _alpha property over time.

Additionally, you have the option of using the mx.transitions.Tween class.

Discussion

You can create the effect of a movie clip fading in or out of your movie by adjusting the instance’s alpha setting over time. By starting out with 100% alpha and gradually adjusting the value to 0%, the movie clip will appear to fade out, and by starting at 0% and gradually adjusting the alpha to 100%, the movie clip will appear to fade in. Or, you can also have the movie clip only fade in or out partially to create your own custom fading effects. For example, you might choose to lower the transparency of one or more movie clips when another is selected. Instead of completely fading those movie clips down to 0%, you can create a dimming effect by lowering the alpha to 50%.

You can create a fading effect at authoring time by using a motion tween between two instances of the same movie clip with different alpha settings. The following steps outline the basic process:

  1. Create the first instance of the movie clip on a keyframe that ...

Get Flash 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.