Categories

Followers

Search This Blog

1 Jan 2012

Flash 8-Lesson 9: Keyframes, Motion Tween, Adding Sound, Stopping the Action, Adding a Button, The Text Tool

Keyframes

Each layer of a Flash movie is divided into frames. Frame numbers appear along the top of the Timeline. At the current time, each layer in your movie is only one frame long. You want your movie to last 60 frames. Inserting a keyframe at Frame 60 will cause each layer to remain on the screen until Frame 60. You use keyframes to specify changes in the animation.
Extend the Sky Layer
  1. Click in Frame 60 of the Sky layer.
  2. Choose Insert > Timeline > Keyframe from the menu.
Extend the Buildings Layer
  1. Click in Frame 60 of the Buildings layer.
  2. Choose Insert > Timeline > Keyframe from the menu.
Extend the Trees Layer
  1. Click in Frame 60 of the Trees layer.
  2. Choose Insert > Timeline > Keyframe from the menu.
Timeline
Create a Layer Named Car
Create a new layer. Name the layer Car.
  1. Make the Trees layer the active layer by clicking on the Trees layer name.
  2. Choose Insert > Timeline > Layer from the menu to create a new layer above the Trees layer.
  3. Choose Modify > Timeline > Layer Properties from the menu.
  4. Type Car in the Name field.
  5. Click OK.
Add the Car to the Stage
  1. Click the first frame of the Car layer.
  2. Move to the Library panel.
  3. Click the icon next to the car and drag a copy of the car onto the Stage.
  4. Choose the Free Transform tool. Handles appear around the car.
  5. Click and drag a corner handle until the car is the appropriate size. Corner handles resize the selected object proportionally.

Motion Tween

Make the Car Move
  1. Choose the Selection tool.
  2. Click and drag the car to the right side of the Stage as shown here.
  1. If the Property inspector is not open, choose Window > Properties > Property from the meun to open the Property inspector.
  2. Click Frame 1 of the Car layer.
Click frame 1
  1. In the Property inspector, choose Motion in the tween field.
Choose motion
  1. Click Frame 60 of the Car layer.
Click frame 60
  1. Choose Insert > Timeline > Keyframe from the menu to make frame 60 a keyframe.
  2. Use the Arrow key to move the car to the left side of the Stage as shown here.
End tween
  1. Choose Control > Play from the menu to play the movie. Your car moves across the Stage.

Adding Sound

To have a horn honk as the car rolls through town, you need to add sound.
Import the Horn Sound
  1. Click here to download the horn sound. Open the Zip file and place the shorthrn.wav file in a folder.
  2. Choose File > Import > Import to Library from the menu. Find and select shorthrn.wav and click Open. The file shorthrm.wav now appears in the Library.
Add the Sound
Create and name a new layer:
  1. Click the Car layer name to make the Car layer the active layer.
  2. Choose Insert > Timeline> Layer from the menu to create a new layer. The new layer appears above the Car layer.
  3. Choose Modify > Timeline > Layer Properties from the menu and type Horn in the Name field to name the layer Horn.
  4. Click OK.
Add sound:
  1. Click Frame 30 on the Horn layer.
  2. Choose Insert > Timeline > Keyframe from the menu to make Frame20 a keyframe.
  3. Move to the Library. If the Library is not already open, choose Window > Library from the menu.
  4. Drag shorthrn.wav from the Library onto the Stage.
  5. Click Frame 20.
  6. Choose Event from the drop-down menu in the Sync field of the Property inspector.
Play the Movie
  1. Choose Control > Test Movie from the menu to play the movie.
  2. Click the Close button to return to Flash Professional 8.

Stopping the Action

If you published your movie now, the car would start moving as soon as the viewer entered the screen. You want the viewer to click on a button to make the car move. In this exercise you will add a behavior to stop any action before the viewer clicks a button. Later, you will add a button for the viewer to click to start the action. You will use behaviors to control the action. Generally you use ActionScript, a scripting language, to control the action in a Flash document. However, behaviors allow you to control some actions even if you do not know ActionScript.
Stop the Action
Add a new layer:
  1. Click the Horn layer to make it the active layer.
  2. Choose Insert > Timeline > Layer from the menu to add a new layer.
  3. Choose Modify > Timeline > Layer Properties from the menu. The Layer Properties dialog box opens.
  4. Type Stop Action in the Name field.
  5. Click OK.
Add a stop behavior:
  1. Choose the Selection tool.
  2. Click Frame 1 on the Stop Action layer.
  3. Choose Window > Behaviors from the menu.
  4. Click the plus sign in the Behavior panel. A context menu opens.
  5. Choose Movieclip > Goto and Stop at Frame or Label. The Goto and Stop at Frame or Label dialog box opens.
  6. Make sure there is a 1 in the Frame number field. This tells Flash to stop at Frame 1.
  7. Click OK.
Play the Movie
  1. Choose Control > Test Movie from the menu to play the movie. Your car should not move.
  2. Click the Close button to return to Flash.

Adding a Button

Buttons have four states: up, over, down, and hit.
The Four Button States
Up The appearance of the button when the pointer is not over it
Over The appearance of the button when you place the pointer over it
Down The appearance of the button when you click it
Hit Defines the area that will respond to a click of the mouse
You want to create a button that is navy in the up state, green in the over state, and brown in the down state.
Create a New Layer
  1. Click the Horn layer to make the Horn layer the active layer.
  2. Choose Insert > Timeline > Layer from the menu to create a new layer.
  3. Choose Modify > Timeline > Layer Properties from the menu.
  4. Type Button in the Name field to name the layer button.
  5. Click OK.
Take the Start Button from the Library
  1. Move to the Library. If the Library panel is not open, choose Window > Library from the menu.
  2. Click on the icon next to Start Button and drag the Start Button onto the Stage.
Start button
Edit the Symbol
  1. Choose Edit > Edit Symbols from the menu to change to the symbol-editing mode.
The Over Frame
  1. Choose the Selection tool.
  2. Click the Over frame to select it.
  3. Choose Insert > Timeline > Keyframe from the menu. The Over frame becomes a keyframe.
  4. Click outside the button to deselect it.
  5. Click the fill color to select it.
  6. Click the Fill color box and select green to change the fill color to green.
The Down Frame
  1. Click the Down frame to select it.
  2. Choose Insert > Timeline > Keyframe from the menu.
  3. Click outside the button to deselect it.
  4. Click the fill color to select it.
  5. Click the Fill color box and select brown to change the fill color to brown.
The Hit Frame
  1. Click the Hit frame to select it.
  2. Choose Insert > Timeline > Keyframe from the menu.
  3. Choose Edit > Edit Document from the menu. You have created a button.
Add the Goto and Play Behavior:
  1. Choose the Selection tool.
  2. Click the button to select it..
  3. Choose Window > Behaviors from the menu if the Behaviors panel is not open.
  4. Click the plus sign in the Behavior panel. A context menu opens.
  5. Choose Movieclip > Goto and Play at Frame or Label. The Goto and Play at Frame or label dialog box opens.
  6. Make sure there is a one in the Frame number field.
  7. Click OK.
Test the Movie
  1. Choose Control > Test Movie from the menu. The Test Movie window opens.
  2. Click the Start Button to make the car roll.
  3. Close the window.

The Text Tool

You need to put a label on the Start Button and add a title to the movie. You will use the Text tool for this.
Text
Add Text to the Button
  1. Click the Text tool to select it.
Text tool
  1. Choose Text > Font from the menu and select a font. I used Arial Black.
  2. Choose Text > Size > 24 from the menu to set the font size to 24.
  3. Click the Fill color box and select gold as the color.
  4. Type Start Movie on the button.
  5. Click anywhere outside the Stage to close the text box.
  6. Use the Selection tool to adjust the placement of the text. Remember, you can also use the arrow keys to change the placement.
  7. Click anywhere outside the Stage to deselect the text box.
Add a Title
  1. Choose the Text tool.
  2. Choose Text > Size > 24 from the menu.
  3. Click the lower left corner of the Stage.
  4. Type My First Movie.
  5. Click anywhere outside the Stage.
Test the Movie
  1. Choose Control > Test Movie from the menu. The Test Movie window opens.
  2. Click the Start Movie button. The movie should play.