A Quick Overview of Masking


Masking in Flash is a two-layer (or more) process. You have a masking layer and you have the layer, or layers , being masked.

When you're creating a mask, you can use the following:

  • Simple shapes

  • Static text

  • Single layer graphic symbols that contain only simple shapes

You can't, however, use the following:

  • Lines (strokes)

  • Gradients

  • Bitmaps

  • Input or dynamic text

So, now you know what you can and can't use as a mask. Are there rules about what can be masked? Yes, there are. Basically, you can mask anything ”except dynamic and input text fields that use device fonts. If you want to mask either a dynamic or input text field, remember to include the font outlines, and you'll be in good shape.

As mentioned, you can use graphic symbols as masks.You also can use movie clips, but, and this is a big but, you have to understand how graphic and movie clips behave when they are in a masking layer. It's not intuitively obvious, and it might not be what you expect.

Movie Clips and Graphic Symbols as Masks

Trying to use a movie clip as a mask can be a frustrating experience if you don't understand how movie clips behave in masking layers. Flash uses only the first frame of the bottom layer of a movie clip as the masking element. Not only that, but if you have nested movie clips, Flash uses the first frame of the bottom layer of the most deeply nested clip. Thus, in general terms, movie clips are not good candidates for masks. However, as you'll see later, movie clips are great candidates for being masked.

Graphic symbols, on the other hand, are a bit more useful than movie clips when you are creating a mask. As with a movie clip, Flash recognizes only the bottom layer of a graphic symbol. However, unlike a movie clip, Flash does recognize multiple frames when you use a graphic symbol as a mask. This means that as long as your animation is contained in one layer, you can use an animated graphic as a mask. There is a caveat here, however. The graphic symbol cannot contain multiple graphic symbols. In other words, if you have a graphic symbol on each frame in your single layer, Flash is going to recognize the first one only. If each frame contains shapes only, you can animate. Thus, you can have shape tweens inside a graphic symbol, because when you shape tween, you're working with simple shapes, not symbols. You also can do frame-by-frame animations using simple shapes inside your graphic symbol. You can get away with motion tweens too, as long as the shapes being tweened are grouped but are not symbols. Make sure you extend your timeline to accommodate the timeline of the graphic.

On the masking layer itself, you can animate whatever you're using as a mask as either a shape or a motion tween. However, you can't use a motion guide to control the path of the tween. It won't work ”don't waste your time trying. You also can have more than one layer under a single mask.

Finally, you need to be aware that you cannot control a masking layer with ActionScript. Even if you use a single-layer , single-frame , named instance of a movie clip, you have no scripting control. You can, however, control the layer being masked with ActionScript, so you have some interesting options with which to work.

The layer being masked isn't governed by the same set of rules as the masking layer, with the exception that you still can't use a motion guide. However, you can use movie clips or graphic symbols in all their glory , and you can control a named movie clip in the layer being masked with ActionScript.

Tip

One of the guidelines you'll see on the Macromedia Web site is to use masks sparingly in your movies ”and with good reason. Masks are CPU- intensive . If you use a lot of animated masking in your movie, you run the risk of grinding your viewer's computer to a halt. That won't make you very popular. When in doubt, refer back to the "Monitoring Your CPU Usage" section in Chapter 5, "Importing, Using, and Optimizing Graphics."


Now that you've had a review of the basics, why not create a mask? The next section will guide you through the process of working with masks. If you're already comfortable with masking, go ahead and skip to the "Masking Examples" section.



Inside Flash
Inside Flash MX (2nd Edition) (Inside (New Riders))
ISBN: 0735712549
EAN: 2147483647
Year: 2005
Pages: 257
Authors: Jody Keating

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net