6.7. Masking Page Elements

Problem

You want to block or reveal one or more elements using another element.

Solution

Create a mask.

Discussion

You can use masks to hide and reveal contents of one or more layers using the contents of another layer. Every working mask has two parts: the mask element(s), whose outline reveals the contents of the masked element(s), and the masked element(s), which is hidden except where it lies directly beneath the mask. Reflecting this distinction, Flash enables you to create special mask and masked layers, which hold mask and masked elements, respectively. A mask layer is a special kind of layer, like a motion guide layer, whose stage contents are not shown in the SWF, but rather are used to reveal whatever is placed beneath them in masked layers. Where the stage is empty in a mask layer, all content in the masked layer is hidden.

To create a mask, follow these steps:

  1. Create the content that you want to use as the mask. You can use any kind of visible content in any combination, including vector art, text (using embedded fonts), symbol instances, and imported bitmaps.

  2. Choose Modify → Timeline → Layer Properties, and select the Mask from Type radio group.

  3. On a different layer, insert the content that you want masked. Again, it can be any kind of visible content.

  4. In the layer stack to the left of the timeline, drag the layer that you want masked so that it is directly beneath the layer that you want to mask it.

When you release, the masked layer will be indented ...

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.