Frames are at the core of any animation, dictating each segment of time and movement. The total number of frames in your movie, and the speed at which they're played back, together determine your movie's overall length.
Not all frames are created equal; different frame types are designed for different animation tasks. Let's take a look at the various frame types that can exist on the timeline.
Placeholder frames are not really frames, but rather rectangular boxes where frames can be placed. They are indicated by the grid on the timeline. Devoid of content, these frames, generated automatically by Flash, make up the majority of the timeline when you begin your Flash project. Although you cannot manually create placeholder frames, they will remain present until you convert them to actual frames. Because your movie needs real frames on at least one layer of the timeline in order to play, it will cease playing once it reaches a point where all layers contain only placeholder frames (Figure 10.14).
Figure 10.14 This scene will not play past Frame 20, because Frame 21 and beyond contain only placeholder frames.
Any time your wish your animation to undergo a visual change or you want an action to occur, you must use a keyframe at that point on the timeline (Figure 10.15). Obviously, frame-by-frame animations require numerous keyframes because you must edit each frame individually. A tweened animation, on the other hand, requires only two keyframesone to begin the tween and one to end it. Changes that occur between the beginning and ending keyframes are mapped by Flash and thus do not require additional keyframes.
Figure 10.15 Keyframes, identified by a vertical line on the left edge of the frame and a small dot, define where changes occur on the timeline.
Although most keyframes contain content that is visible on the stage, they can also be blankusually the result of removing a movie element from an animation. Every new project you begin in Flash starts with a blank keyframe on Frame 1 of Layer 1. A keyframe with content visible on the stage is identified by a solid black dot; a blank keyframe is identified by a hollow dot; and a keyframe with an attached action is identified with a small a.
Regular frames always follow keyframes and contain the same content as the last keyframe on the same layer. Confused? Let us explain.
A keyframe on the timeline denotes a change; the regular frames that follow a keyframe determine the duration of that change. Let's say you have a movie element that you want to appear in the middle of the stage at the beginning of your movie: You would need to place that element on a keyframe at Frame 1. If you also want it to remain in the middle of the stage until it jumps to the top-left corner at Frame 11, you would make Frames 2 through 10 regular frames (since the element does not move or change as these frames play), and then add a keyframe at Frame 11 to specify a change in the element's position on the stage (Figure 10.16).
Figure 10.16 Regular frames always follow keyframes, and contain the same content as the last keyframe on the same layer.
A keyframe and the span of regular frames that follow it are known as a keyframe sequence. The timeline can contain any number of keyframe sequences. If the keyframe in a sequence contains graphical content that is visible on the stage, the regular frames that follow it will appear gray. If the keyframe in a sequence contains no graphical content, the regular frames that follow it appear white (Figure 10.17).
Figure 10.17 If the keyframe in a sequence contains content visible on the stage, the regular frames that follow in the sequence are shaded gray. If the keyframe contains no content visible on the stage, the regular frames that follow are white.
Tweened frames are always part of a tween sequence consisting of two keyframes and any number of frames in between. The frames between the two keyframes represent computer-calculated graphics.
You can perform two types of tweening with Flash: motion tweening and shape tweening. You use motion tweening to alter the size, position, rotation, and other aspects of symbols, groups, or text blocks in your animation. You use shape tweening to morph one simple shape into anotherfor example, smoothly transforming a red circle into a blue square or the letter T into the letter I (Figure 10.18). Shape tweening only works with simple shapes such as lines and vector shapes, not with symbols or groups. If text is to be used in a shape tween, you must first break it apart, then place each letter you plan to tween on a separate layer.
Figure 10.18 Motion tweening controls an element's size, position, rotation, and so on. Shape tweening morphs one simple shape into another.
If you plan to simultaneously tween multiple elements in a scene, each tween must be placed on its own layer. In other words, you can't tween separate movie elements on the same layer at the same time.
A motion-tweened sequence is identified by two keyframes separated by intermediate frames with a black arrow and light-blue background. A shape-tweened sequence is identified by two keyframes separated by intermediate frames with a black arrow and light-green background. A problem in a tween sequencefor example, a tween that lacks a starting or ending keyframeis indicated by a dashed line (Figure 10.19).
Figure 10.19 A motion tween (top layer), a shape tween (middle), and a problem tween (bottom).
Working with Frames
Now that you're familiar with the various frame types and how to use them in creating animations, let's look at the ways you can work with them on the timeline. For more information about using frames, see "Creating Animation" later in this chapter.
Before you can move, duplicate, or change a frame, you must first select it. When a frame is selected, the playhead automatically moves to that frame and the contents of its layers appear on the stage.
To select an individual frame:
Click a frame once to select it.
The frame will appear highlighted. The selected frame becomes the current frame, and any commands you enter pertaining to frames will affect it.
To select a range of frames:
Click the first frame you want to be part of the range, drag to the last frame you want included, and then release.
All selected frames will appear highlighted. You can now move, delete, and duplicate them as a whole.
To select a keyframe or tween sequence:
Double-click once on any frame that is part of the sequence.
The sequence will appear highlighted (Figure 10.20). You can now move, delete, and duplicate the sequence.
Figure 10.20 A frame sequence is highlighted to indicate that it is currently selected.
Moving and duplicating frames
By moving frames, you can edit the points where changes occur along the timeline, such as the starting and ending points of frame sequences or when frame actions occur. By duplicating frames, you can use their content elsewhere on the timeline without having to re-create that content.
To move or duplicate frames:
Select a frame, range of frames, or frame sequence.
Click and drag the selected frames to a new location on the timeline, then release (Figure 10.21).
Figure 10.21 Drag selected frames to their new location, and release.
To duplicate the frame or range of frames at a new location, hold down the Alt key (Windows) or the Option key (Macintosh) while you drag. As you drag, a plus sign (+) will appear next to the cursor indicating that you are in the process of duplicating the selected frames.
Extending or shortening a frame sequence
Selecting while holding down the Ctrl key (Windows) or the Command key (Windows), then moving the beginning or end frame of a keyframe sequence, alters the length of the sequence on the timeline and thus the duration of its content in the overall animation. As you drag, a double-headed arrow will appear next to the cursor indicating that you are in the process of shortening or lengthening a frame sequence. Selecting, then moving the beginning or end frame of a tween sequence, determines not only its length on the timeline and its duration in the overall animation, but also how many regular frames the tweening process generates between the beginning and ending keyframes.
Adding and inserting regular frames
Adding or inserting frames at any point along a layer changes the timeline position of all frames on that layer located to the right of the added or inserted frame(s).
To add regular frames to the timeline:
Select a placeholder frame on the timeline.
Choose Insert > Frame.
Regular frames are added until the selected placeholder frame is reached.
To insert regular frames within an existing range of frames:
Select a single frame, range of frames, or frame sequence within an existing range of frames.
Choose Insert > Frame.
The same number of frames you selected will be inserted onto the timeline; the previously selected frames will be moved to the right of the newly inserted ones.
As mentioned earlier, you use keyframes on the timeline to define when changes occur in your animation. Thus, your animation is likely to contain numerous keyframes. When you add a keyframe to a layer, you have the choice of adding a normal or blank keyframe. When adding a normal keyframe, any graphical content (instances of symbols, text elements, and so on) included in the last keyframe on the same layer is automatically duplicated in the new keyframe. Adding a blank keyframe places a point on the timeline where that layer's contents are no longer visible Normal keyframes are used to signify a change in an animation while keeping the content of the animation visible. With a blank keyframe, the change is the actual removal of content (Figure 10.22).
Figure 10.22 The difference between adding a normal keyframe and a blank keyframe.
To add a keyframe to the timeline:
Select a placeholder or regular frame on the timeline.
Choose Insert > Keyframe or Insert > Blank Keyframe to add a keyframe. If the frame you selected is a placeholder frame, regular frames will be added up to the point of the newly created keyframe. If the selected frame is a regular frame, Flash simply converts it to a regular or blank keyframeas you specify.
To add a range of keyframes to the timeline:
Select a range of frames or a frame sequence.
Choose Modify > Frames > Convert to Keyframes or Convert to Blank Keyframes.
A range of keyframes will be added.
Removing frames at any point on a layer changes the timeline position of all frames on that layer located to the right of the frame(s) you remove.
To remove frames:
Select a single frame, range of frames, or frame sequence.
Choose Insert > Remove Frame.
Reversing frames will invert the timeline order of a selected span of frames, causing the graphical content of the selected frames to play in reverse.
To reverse frames:
Select a sequence of at least two frames.
Choose Modify > Frames > Reverse.
Adding frame actions
Frame actions enable your movie to perform a specified action when the timeline reaches a particular frame during playback. For more information, see Chapter 12, "Getting Started with ActionScript."
To add a frame action:
Right-click (Windows) or Control-click (Macintosh) on the keyframe to which you would like to add an action, and select Actions from the menu that appears.
The Actions panel will appear next.
Click the Add Action button to add any actions to this frame, then close the Action panel.
The keyframe display now includes a small a to indicate that an action has been assigned to it.
Labels and comments
You use frame labels in Flash to identify a particular keyframe in your movie. This is especially useful when assigning frame or button actions to certain frames in your movie (see Chapter 12, "Getting Started with ActionScript").
Say you've set up your movie so that several buttons, when clicked, begin playing your movie at Frame 35. However, you later decide that you want to delete five frames from the beginning of your movie. Unfortunately, this means that the content which once began at Frame 35 will now begin at Frame 30but the buttons you set up earlier will still go to Frame 35 when the viewer clicks themnot the result you were looking for. Using frame labels allows you to get around this problem.
By assigning a labelfor example, MyLabelto Frame 35 and setting all of those button-clicks to begin playing your movie from that label, you can add and delete frames as needed: Regardless of how many scenes are in your movie, those button clicks will always point to MyLabel.
Frame comments allow you to write notes, or comments, in frames of your moviea good way to remind yourself of the thought process that informed some portion of your movie's timeline.
Because frame labels are exported with your final movie, they can affect its overall file size (albeit minimally). For this reason, you should use short, descriptive labels. Frame comments, in contrast, are not exported, so you can include as much information in them as you want.
Wherever display room on the timeline permits, frame labels are identified by a small red flag followed by the label name, and frame comments are identified by two green forward slashes followed by the comment text (Figure 10.23). Where room on the timeline does not permit, only icons appear, with no accompanying text.
Figure 10.23 A frame label and a frame comment.
To add a label or comment to a keyframe:
Click the keyframe once to select it.
Choose Window > Properties. The Property inspector will appear.
In the Frame Label box (Figure 10.24), enter the text you would like to use as a label for this keyframe. Entering two forward slashes (//) prior to entering any text creates a frame comment instead.
Figure 10.24 The Frame Label box on the Property inspector.
The label or comment will appear on the timeline.
If you pause your cursor over a frame on the timeline, a "tooltip" appears with a description of the frame type. If the frame you pause the cursor over contains a label or comment, the label name or comment text is displayed.
By identifying a keyframe on the main timeline as a named anchor (in essence, an enhanced frame label), you make it possible for Web browsers to recognize those points as regular HTML pages. This means that viewers can navigate Flash movies using the Back/Forward buttons of their Web browsersjust as they would a typical Web page. As the viewer interacts with your movie, Flash records his or her navigation pathso that the user can then employ the browser's Back/Forward buttons to move backward or forward in the movie.
In addition, named anchors make it possible to bookmark keyframeswhich means users can quickly return to a given point in a Flash movie simply by clicking that bookmark (again, just like a typical HTML page). Both of these capabilities address issues that had caused some companies to limit the use of Flash on their sites.
Due to issues beyond Macromedia's control, Named anchors do not work on Macintosh-based browsers.
As you'll soon see, once you've assigned a frame label to a keyframe, it's easy to create a named anchor.
To create a named anchor:
Assign a label to a keyframe, as described in the previous section.
This will cause the Named Anchor checkbox underneath the frame label box to become selectable.
Check this box to create an anchor (Figure 10.25).
Figure 10.25 The Named Anchor checkbox only becomes selectable if a keyframe has been given a frame label.
The frame label icon on the keyframe changes to a neat little anchor icon, indicating the existence of a named anchor.
Choose File > Publish Settings to open the Publish Settings dialog box.
Select the HTML tab and choose the Flash with Named Anchors template (Figure 10.26).
Figure 10.26 The Flash with Named Anchors template must be used for named anchors to work in your published movie.
Although your movie doesn't need to be published (exported) immediately, when it is, it must be published using this template in order for named anchors within your movie to function. For more information about publishing a movie, see Chapter 20, "Publishing."
When a user navigates to a keyframe containing an anchor, the name of that frame label/anchor will appear in the address bar of the viewer's browserso choose your frame label names wisely.
Since many developers use scenes to separate content within a movie, you can enable Flash to automatically insert a named anchor at the beginning of each new scene. To do this, open the Preferences dialog box (Edit > Preferences...), select the General tab, and then check the Named Anchor on Scene option.
If you've ever watched a pencil-and-paper animator, you've probably noticed that he or she customarily works with a pencil in one hand and a couple of pages, or eventual frames, of the animation in the other. While drawing on the current frame, the animator will flip among frames that precede and follow it to get an idea how the drawing sequence will emulate movement when it's eventually played. Flash provides similar functionality in the form of onion-skinning, which allows you to view and edit multiple frames simultaneously.
To view multiple frames using onion-skinning:
Click the Onion Skin button (Figure 10.27).
Figure 10.27 The Onion Skin buttons.
This brings up a set of onion-skinning markers, which appear next to the playhead on the timeline (for more information about onion-skinning markers see "Onion-Skinning Markers" a little later in the chapter). The content of the frames between these two markers now appears on the stage, some before the current frame and some after (Figure 10.28). The current frame is the one over which the playhead is positionedand in this mode, it is the only one whose contents are editable. Content on uneditable frames appears dimmed in color. Dragging the playhead allows you to apply onion-skinning to other frames.
Figure 10.28 When onion-skinning is turned on, the stage reflects the content of multiple frames, with the current frame's content the most boldly defined.
You will not be able to see content on currently locked or hidden layers when using onion-skinning. Thus, you can lock or hide layers to specify which content is visible and editable when onion-skinning.
To view onion-skinned frames as outlines:
Click the Onion Skin Outlines button.
This option works much like the Onion Skin button, except that content on all but the current frame appears as outlines. You can assign a different outline color to each frame to help identify which layer's content needs to be edited.
Editing multiple frames
Normally, you can only edit content on the current frame when using onion-skinning; however, by making multiple frames editable during onion-skinning, you can select, move, rotate, resize, and otherwise alter the content of multiple frames simultaneously. This is a great feature for moving entire sections of content on the stage (Figure 10.29). For example, if you wanted to move a layer's content by 50 pixels, you could manually place the playhead at a frame, move the layer's contents, move the playhead forward a frame, move the layer's contents, and so forth. However, this is a tedious process as well as a waste of time. By editing multiple frames simultaneously, you can move everything on the layer across multiple frames simultaneously.
Figure 10.29 The Edit Multiple Frames feature lets you edit the content of multiple frames simultaneouslyfor example, moving the content on several at once, as shown here.
To make multiple frames editable:
Unlock and make visible all layers whose content you wish to move.
Click the Edit Multiple Frames button.
All content on unlocked and visible frames between the onion-skinning markers becomes editable, meaning you can move, rotate, and otherwise edit it as a whole.
You use the onion-skinning markers to determine the range of frames that are onion-skinned. Usually, the markers maintain their positions relative to the playhead; however, you can also anchor them while the playhead moves. You can adjust onion-skinning markers manually or via the Modify Onion Markers pop-up menu.
To move the onion-skinning markers manually:
Click a marker and drag it to its new position, then release. You can't move either marker past the position of the playhead.
To modify the onion-skinning markers:
Click the Modify Onion Markers button.
This brings up the Modify Onion Markers pop-up menu, which includes the following options:
Always Show Markers. Normally, onion-skinning markers only appear when onion-skinning is turned on. This option causes them to be displayed even when it's not.
Anchor Onion. This option anchors, or locks, the onion-skinning markers to their current positionthat is, they remain stationary rather than retain their positions relative to the playhead.
Onion 2. This option lets you quickly set onion-skinning markers two frames before and two frames after the current frame (playhead position).
Onion 5. This option lets you quickly set onion-skinning markers five frames before and five frames after the current frame.
Onion All. This option onion-skins all the frames in the current scene. Obviously, this works best if you're viewing a limited number of layers; lock or hide certain layers to make them invisible.