Instruction: Instructor will show students how to import and play simple audio files. Instructor will also show how to create simple controls for those sounds.
Description: This lab consists of three parts. Exercise 1 involves incorporating sinple sounds into an animation. Exercise 2 involves lip syncing a character. Exercise 3 involves using simple ActionScript to control sounds.
Create a new flash document, set the frame rate to 24 fps (Modify > Document).
Create a circle, making sure to select both the fill and the stroke of the circle, convert it to a graphic symbol named "Ball." (it now appears in your library)
Delete the ball from the stage; you should still have the symbol in the library.
Go to Insert>New Symbol to create a new movieclip symbol named "Bouncing Ball"
Make sure you are editing your newly made "Bouncing Ball" symbol;
Drag an instance of "Ball" onto the stage. Set it off to the left
Click on frame 80 and add a new keyframe
Right click between 1 and 80 and create motion tween
Insert new layer (we'll delete it later)
Use the pen tool to draw a bounce path (click drag for handles at the top of the bounce path, but only click and release for bounce points at the bottom of the path)
Use the selection tool to select the entire path, ctrl+x to cut it.
Delete the new layer.
Make sure the motion tween is selected in the timeline
Paste the path onto the screen - the ball should be bound to the path now.
Above the timeline, click the "Scene 1" tab to go back to editing the main timeline.
Drag an instance of the "Bouncing Ball" symbol to the stage. Position the ball to the left of the stage.
Press ctrl-enter to test the animation. The ball bounces, but it is very chunky and unrealistic.
Double click the "Bouncing Ball" symbol in the library to edit it.
Click anywhere along the first tween, then change its X and Y to have a Simple(slow) ease and set the ease property to 100, this makes the tween start quickly and slow down near its end; it’s known as easing out. It also makes the ball look as though it was thrown fast and slows down as it bounces.
Play the animation again; hopefully it looks smoother now.
Make sure you are still editing the Bouncing Ball symbol
Make the ball squish:
Find the frame of the first point where the ball bounces
Use free transform to squish the ball on that frame
On the very next frame, use free transform to return the ball to regular shape
You may have to set the ball to normal size on the frame immediately before the squish as well.
Repeat the ball squish for the second point where the ball bounces
Note: you have to do this after setting the ease because the ease changes the trajectory of the ball as well as the frame in which the ball bounces.
Add sound effects:
Add a new layer called "SFX."
Download the sound file "boing_2.wav" (you can search and find this file online). You will use this sound file in this exercise.
Import the sound file "boing_2.wav" by selecting file>import>import to library, or drag the file directly into the library from outside of flash.
Find the frame in which the ball is at its lowest point and create a keyframe on that frame ofthe SFX layer. Do this again for the second lowest point (the second bounce).
While in the new keyframe, drag an instance of the sound onto the stage from the library.
You won’t see anything different on the stage, but the SFX layer now displays the sound.
Select that frame, in the properties panel, set sync: to event, then click the edit button to the right.
In between the two wave images is the sound timeline, it has dashes and numbers in seconds on it. There are two bars on the timeline, one at the beginning and one at the end of the sound.
Move the first bar to the right to cut out the short "quiet space" at the beginning of the sound, taking the empty space off.
Add play button and ActionScript
In scene 1, select the ball, in properties, give it instance name: theBall
Create a play button and place it on the stage. Instance name: btnPlay
On the main timeline, insert a new layer and call it ActionScript. Copy and paste this code into the first frame of that layer:
Open it. Go to the library. Select rockin1.wav. Right click > Copy.
Go back to your flash file, in the library, Right click > Paste.
Close and delete the flash file you just downloaded.
On the main timeline, insert a layer: ActionScript. On frame 1, open the Actions panel and type (this prevents sound from playing when the file swf first loads): stop(); flash.media.SoundMixer.stopAll();
Edit the StartButton
symbol in the library.
On the down state in the SFX layer, drag an instance of rockin1.wav onto the stage. It will appear on the timeline.
Change the sync of the sound to Event.
Test the movie and press the green button. As you press the button multiple times, you will notice it plays multiple instances of the sound on top of one another. Sync:Event tells Flash to play the sound every time it reaches that frame.
Change the sync of the sound to Start and test the movie again. This time, only one instance of the sound plays, no matter how many times you press the button. Sync:Start tells Flash to start the sound, if it is already playing, it ignores this command.
Edit the btnStart symbol one more time; change the sound from "repeat" to "loop". Obviously, this tells the sound to continue looping itself. Rockin1.wav is a sound intended to loop so there will be no break in the music when it loops.
Edit the StopButton symbol in the library.
On the down state in the SFX layer, select "rockin1.wav" from the "sound" dropdown in the properties bar. This does the same thing as dragging sounds from the library, but can be a timesaver if you end up with a lot of sounds.
Change the sync of the sound to Stop
Test the movie. After pressing the green button, the sound will loop until you press the red button.
Make the speaker thump
Create a new symbol. Name: Speaker Thump. Type: Movie Clip.
Drag an instance of Speaker onto its stage.
Insert a frame at frame 12.
Insert a keyframe at frame 7.
Select one of the first 6 frames and create a motion tween.
On frame 6, with the selection tool selected, use the arrows to nudge the speaker over 4 and down 4.
Select one of the last 6 frames and create a motion tween.
On frame 7, with the selection tool selected, use the arrow keys to nudge the speaker over 4 and down 4.
Enter to test the symbol
On the main timeline, delete the old speaker symbol from the stage and drag an instance of Speaker Thump onto the stage.
On the main timeline, select the Speaker Thump. Change its instance name to: thump1
On the main timeline, select the StartButton. Change its instance name to: btn_start
On the main timeline, select the StopButton. Change its instance name to: btn_stop
In the main timeline, click on the first frame of the actions layer, then open the actions panel.
Add this line of code on line 3: thump1.stop();
This tells the movieclip instance "thump1" to stop playing immediately as the movie starts. This prevents the speaker from thumping when there is no music playing.
Add the following code below the existing line of code (The red lines with forward slashes denote comments and don’t affect the code.).