Accessibility
Adobe
Sign in Privacy My Adobe

Using Flash for the first time—Part 2: Adding symbols, animation, and ActionScript


Table of Contents

Adding animation to a timeline

You have already used the Timeline in Part 1 of this tutorial to insert new layers and add content onto those layers. In Part 1, you added assets to the Stage and a frame on the Timeline. You might have noticed that after you add content on a frame, a filled circle appears on the frame to signify content on that frame. Whenever there's new or changed content on a frame, it's called a keyframe and has a filled black dot on the frame. A keyframe is a frame where you define changes in the animation, or a frame that has content on it. An empty keyframe has a hollow circle. For more information on different kinds of frames, do a search on “frames and keyframes” (with quotes) in the Help panel (F1).

You create an animation in a Flash document by adding content to a timeline. When the playhead moves across a timeline, those individual frames play; when they're played in quick succession (like a flipbook or succession of frames on a reel of film), you can create an animation.

When you create a frame-by-frame animation, every frame is a keyframe. In a tweened animation, you define keyframes at significant points in the animation and let Flash create the contents of frames in between. Flash displays the interpolated frames of a tweened animation as light blue or light green with an arrow drawn between keyframes. Because Flash documents save the shapes in each keyframe, you should create keyframes only at the points in the animation where something changes.

Creating a frame-by-frame animation

To create a frame-by-frame animation, follow these steps:

  1. Choose Modify > Document.

    The Document Properties dialog box opens. This is the dialog box you used to change the dimensions of the banner in Part 1. Now you want to change the frame rate for the banner.

  2. Change the number in the frame rate text box to 18. Click OK to apply the new setting.

    A higher frame rate means that your animation plays smoothly, more so than when you had it set to 12 frames per second (fps). Changing the fps setting means that the main timeline and movie clip timelines all play at the specified frame rate.

    Note: An increased frame rate also means that there is a slightly increased demand on the user's computer (or CPU) to render the extra frames each second.

  3. Double-click the join_us symbol instance on the Stage.

    This opens the symbol in symbol-editing mode (see Figure 5). In this mode, you see the movie clip symbol's timeline, which runs independently of the timeline for the main FLA document (the one you saw prior to double-clicking the symbol). This means you can have animations that play and stop independently from animations on the main timeline. Remember that a movie clip still plays at the document's frame rate (18 fps).

    Symbol-editing mode

    Figure 5: In Symbol-editing mode, the symbol you're editing appears normal, while other items on the Stage are dimmed. Changes you make in this mode apply to every instance of the symbol in your FLA file.

    When you enter this mode, it means you edit the symbol itself, not just the single instance on the Stage. Any changes you make on this Timeline (which is the movie clip's Timeline) apply to every instance of the symbol you use in the FLA file.

    You can tell that you're editing a symbol by looking at the edit bar (see Figure 6).

    the edit bar

    Figure 6: Use the edit bar to navigate a document. The edit bar might be above or below the Timeline. The rightmost icon (in this case, join_us) indicates the current symbol being edited.

    Scene 1 refers to the main timeline of the FLA document. You can click this button to return to the main Timeline. The names after it point to the symbol you're editing. If the symbol is nested within other symbols, this path might contain several names. In Figure 6, you can see that you're editing the join us symbol that's on the main Timeline (Scene 1).

  4. With the Selection tool, click and drag around the content that's inside the movie clip and press F8 to convert it into another new movie clip symbol.
  5. In the Convert to Symbol dialog box, type the name nested_mc in the Name text box, select Movie clip, and then click OK.

    A new movie clip is added to the library. Also notice that two layers on the timeline are now empty. You can tell that these layers are empty because the frames have unfilled circles, which represent no content, and the topmost layer has a filled circle (meaning it has content). In the following steps you delete the layers that no longer contain artwork.

  6. Select the text bg layer on the Timeline and then click the Delete Layer button below the layer name (it looks like a trash can).
  7. Repeat step 6 for the star layer. After you’re finished, you should only have one layer on the timeline called text fg. You can rename this layer to star if you wish.
  8. Select Frame 15 and then choose Insert > Timeline > Keyframe.

    Tip: Press F6 to quickly insert a new keyframe.

    This command inserts a new keyframe, which means you can modify the content on that frame to create animation. Currently, the content on Frame 15 is duplicated from the content on Frame 1. When you modify Frame 15 in a future step, the modifications won't change the content on Frame 1.

  9. Select Frame 30 and press F6 to insert a new keyframe. The keyframe duplicates the content from Frame 15. That means the content on all three frames is the same.
  10. Select the movie clip instance on Frame 15, and then open the Property inspector (Window > Properties > Properties).

    Note: Make sure you select the instance on Frame 15, not just the frame. You can first select the frame on the Timeline (or move the playhead to Frame 15) and then select the movie clip instance on the Stage in order to see the correct context of the Property inspector, as shown in Figure 7.

  11. Select Brightness from the Color pop-up menu.
  12. Change the slider value to 75% (see Figure 7).

     

    Change the brightness

    Figure 7: Change the brightness of the movie clip instance.

    The brightness changes for the instance on Frame 15. The instances on Frames 1 and 30 do not change. This means that you can now add a motion tween that animates the brightness value between Frames 1 and 15, and then from Frames 15 to 30. After playing Frame 30, the playhead loops back to Frame 1 and the animation starts again.

    Tip: You could also change the alpha or tint values using the same procedure. Alpha tweens are more processor-intensive than tweens that change the brightness or tint of your animation. Try to avoid processor-intensive procedures whenever possible.

  13. Select the instance on the Stage at Frame 15 again, and then select the Free Transform tool in the Tools panel. Select the lower right handle and drag it towards the center of the image to make it smaller (see Figure 8).

     

    Free Transform tool

    Figure 8: Resize the instance using the Free Transform tool.

  14. Click and drag the red toggle (playhead) from left to right across the Timeline.

    The star should jump between large and dark, to small and “bright” (or light-colored). This is essentially a frame-by-frame animation, because the graphic changes between frames without any “tweening” applied: you have a succession of graphics that change when the playhead reaches the frame. However, in this case we do want to apply a tween to this “animation”, because it is too choppy and a smooth transition will look nicer. To learn how to apply a tween, read on!

Creating a tweened animation

You can create several kinds of animation in a FLA file. In this section of the marathon tutorial series, you will create a tweened animation or motion tween. A motion tween is an animation where you define properties such as position, size, and rotation for an instance at one point in time, and then you change those properties at another point in time. In this animation, you change the brightness and size of the instance (already defined in the previous exercise).

For information on different kinds of tweens, do a search on “about tweened animation” (with quotes) in the Flash Help panel (F1).

  1. Select any frame between Frames 1 and 15, and then select Motion from the Tween pop-up menu in the Property inspector.

    The span of frames changes color and an arrow appears between Frames 1 and 15 (see Figure 9). Notice how the options in the Property inspector are different when you select a frame compared to when you select a movie clip instance (see Figure 7 earlier).

    Tip: You can also right-click (Windows) or option-click (Mac) the frame and select Create Motion Tween from the context menu instead.

  2. Select any frame between Frames 15 and 30, and then select Motion from the Tween pop-up menu in the Property inspector to create a second animation.

     

    motion tween

    Figure 9: Create a motion tween between Frames 1 and 15, and then 15 and 30, on the movie clip's timeline.

  3. Click the playhead and drag it across the movie clip's Timeline to test (or scrub) the animation.
  4. Select Control > Test Movie.

    Tip: A quicker way to test your SWF file is to use keyboard shortcuts. Press Control+Enter (Windows) or Command+Return (Mac) to test the file.

    The test environment opens where you can see the animation. Notice how it loops, appearing to fade in and out because of the change in brightness. By default, the playhead returns to Frame 1 and replays the animation after it reaches the final frame on the timeline in the movie clip. This means the animation loops repeatedly unless you tell it to stop. You will find out how to do this later in the section called Writing simple ActionScript.