4.4. Working with Layers
The more layers you have, the more important it is to keep them organized. In this section, you see how to give your layers meaningful names , so that you can remember which images, sounds, or actions you placed in which layers. You also see how to order your layer so that your composite images appear just the way you want them and to copy and paste your layers (to cut down on the work you have to do to create similar layered effects).
4.4.1. Renaming Layers
The names that Flash gives the layers you createLayer 1, Layer 2, Layer 3, and so onaren't particularly useful when you've created 20 layers and can't remember which layer contains the ocean background you spent 10 hours drawing. Get into the habit of renaming your layers as soon you create them, and you'll have an easier time locating the specific elements you need when you need them.
This section builds on the example you created in "Adding Content to Multiple Layers" earlier in this chapter. If you haven't had a chance to work through that section, you can download flowers.fla from this book's "Missing CD" Web page and use it instead.
Figure 4-9. Top: This animation contains three layers: one containing a motion tween of a buzzing fly; one containing the path the fly takes as it buzzes around the frog's head; and one containing the highly interested frog. In some situations, showing all layers is fine, but here it's confusing to see all those images on the Stage at the same time.
| UP TO SPEED |
Flash gives you two different ways to change the properties associated with your layers: for example, the name of your layer, whether you want to show the content of a layer on the Stage or hide it, whether you want to lock a layer or leave it editable, and so on.
One way is clicking the icons in the Layers window. (That's the approach described in this chapter.) The other way is by using the Layer Properties dialog box.
To display the Layer Properties dialog box, click to select a layer; then do one of the following:
The Layer Properties dialog box lets you change any or all of the following layer properties in one fell swoop:
After you make your changes, click OK to tell Flash to apply your changes to your layer.
Note: Instead of double-clicking the layer name, you can use the Layer Properties dialog box to rename your layer. Check out the box on Section 4.4.1 for details.
Click inside the text box and then type birds ; then click anywhere else in the workspace .
Flash displays the new name for your layer.
Repeat steps 1 and 2 for Layers 3, 2, and 1, renaming them cloud, flowers , and fence , respectively .
Figure 4-10. Top: The Layers area of the Timeline isn't particularly big, so make sure you keep your layer names short and sweet. (Even if you tell Flash to expand the layer, as described in the box on Section 4.4.1, the space for the layer name doesn't increase.)
Bottom: If you can't remember what a particular layer contains, check the Stage: When you double-click a layer name to rename it, Flash automatically highlights the content associated with that layer.
4.4.2. Copy and Paste a Layer
Earlier in this chapter, you saw how to copy and paste individual series of frames . But Flash also lets you copy and paste entire layersuseful when you want to create a backup layer for safekeeping, or when you want to create a duplicate layer to change slightly from the original.
For example, if you want your animation to show an actor being pelted with tomatoes from different angles, you can create a layer that shows a tomato coming in from stage rightperhaps using a motion or shape tween (Chapter 3). Then you can copy that layer, paste it back into the Layers window, rename it, and tweak it so that the tomato comes from stage left. Maximum effect for minimum effort: That's what copying and pasting gives you.
To copy and paste a layer:
In the Layers window, click the name of the layer you want to select .
Flash highlights the layer name, as well as all the frames in the layer.
Select Edit Timeline Copy Frames .
If you don't have a layer waiting to accept the copied frames, create a new layer now before going on to the next step.
In the Layers window, select the name of the destination layer. Then choose Edit Timeline Paste Frames .
Flash pastes the copied frames onto the new layer, beginning with the first frame. It also pastes the name of the copied layer onto the new layer.
4.4.3. Reordering (Moving) Layers
Flash always draws layers from the bottom up. For example, it displays the contents of the bottom layer first; then, on top of the bottom layer, it displays the contents of the next layer up; then, on top of both of those layers, it displays the contents of the third layer up; and so on. Figure 4-11 shows you an example.
Figure 4-11. Flash treats layers the same way you treat a stack of transparencies : The image on the bottom gets covered by the image above it, which gets covered by the image above it, and so on. Stacking isn't an issue if none of your images overlap. But when they do, you need to decide which layers you want in front and which behind. Here, for example, the cloud's covering up both the flowers and the fence, so it needs to be reordered.
Because Flash always displays layers from the bottom up, if you want to reorder your layers, you need to reorder their position in the layers list. Doing so is simple: All you have to do is click the name of a layer to select it and thenwithout letting up on your mousedrag the layer to reposition it. Figure 4-12 shows you an example.
4.4.4. Delete a Layer
Flash gives you three different ways to delete a layer:
In the Layers window, right-click the layer you want to delete and then, from the shortcut menu that appears, choose Delete Layer.
Drag the layer you want to delete to the Trash can (see Figure 4-13).
Figure 4-12. Moving a layer is easy: Just click to select a layer and then drag it to reposition it (and change the order in which Flash displays the content of your frames). Here, the cloud layer has been moved to the bottom of the list, so it now appears behind the other images. The birds layer is in the process of being moved; you can tell by the thick gray line you see beneath the cursor.
Click the layer you want to delete to select it (or Shift-click to select several layers) and then click the Trash can.
Whichever method you choose, Flash immediately deletes the layer or layers (including all the frames associated with that layer or layers) from the Layers window.
Tip: If you delete the wrong layer by mistake, choose Edit Undo Delete Layer.
4.4.5. Locking and Unlocking Layers
Working with layers can be confusing, especially at first. So Flash lets you lock individual layers as a kind of safeguard, to keep yourself from accidentally changing content you didn't mean to change:
To lock a layer , click the Unlocked icon (the dot in Figure 4-14) next to the layer you want to lock. When you do, Flash turns the dot into a little padlock icon and deselects any objects that you'd selected on the Stage in that layer. If you locked the active layer, Flash draws a red slash through the pencil icon next to the layer's name as a visual reminder that you can't edit it.
To unlock a layer , click the Locked icon (the padlock you see in Figure 4-14) next to the layer you want to unlock. Instantly, the padlock turns into a dot, Flash reselects your objects, and you can edit them once again on the Stage.
To lock (or unlock) all of your layers all at once , click the Lock/Unlock All Layers icon. Click the icon again to return to unlocked (or locked) layers.
To lock all layers except the one you're currently editing , Alt+click (Windows) or Option-click (Mac) the unlocked icon next to the layer you're editing.
Figure 4-14. Here, the cloud and fence layers are unlocked, and the birds layer (and the selected flowers layer) are locked. Some people get into the habit of locking all the layers they're not currently editing. That way, they can't possibly add a shape or a tween to the wrong layer.
Note: If you try to edit a locked layer, Flash displays a warning dialog box that gives you the opportunity to unlock (and then edit) the layer.