You might want to play sounds in different situations such as:
Before we go any further, be aware that there are two kinds of sounds in Flash:
1. Make sure the library panel of your document is open (Ctrl-L)
2. Import a sound into your document’s library with File > import. You can find some MP3 sounds in My Computer > Classes > Ward > ICT all levels > MP3 Sounds. Choose a sound no more than a couple of seconds long.
3. Test the sound by selecting it in the library then pressing the play button above the waveform.
4. Open the common library ‘Buttons’
Window > Common Libraries > Buttons
5. Drag a Button onto the stage
6. Using the selection tool (black arrow), go into symbol editing mode by double-clicking the button on the stage.
7. Add a new layer and rename it ‘Sound Effect’
8. Click where the Sound Effect layer intersects the Down column and insert a blank keyframe (right-click)
9. Drag the sound from the library onto the stage (notice the line that appears in the selected ‘down’ frame.
10. To leave symbol editing mode, click ‘Scene 1’ above the timeline. The timeline should return to its normal state;
11. Press Enter or Ctrl-Enter to test.
1. Make sure the library panel of your document is open (Ctrl-L)
2. Import a sound into your document’s library with File > import. You can find some MP3 sounds in My Computer > Classes > Ward > ICT all levels > MP3 Sounds. If you already have a sound attached to a button then use a different sound for this purpose.
3. Make your movie at least 48 frames long. If your movie is not already at least that long then insert a frame (not a keyframe) by right-clicking frame 48 in the timeline and choosing ‘insert frame’.
4. Add a new layer and rename it ‘Sound Effect’.
5. Insert a frame in the Sound Effect layer so that this layer contains the same number of frames as the other layer.
6. With the Sound Effects layer still selected, insert a keyframe somewhere between frame 1 and frame 48 (right-click and choose ‘insert keyframe’. Only keyframes can carry the instruction to begin playing a sound.
7. Make sure the keyframe is selected by clicking on it. Its properties are now displayed in the properties panel.
8. In the Properties Panel, select the sound you wish to begin playing when this frame is reached, then set the Sync setting to start. Notice that the waveform of the sound now appears in the Sound Effects layer. Leave the Repeat setting at 1 so that the sound plays once only each time the sound is reached (it’s possible to have sound play several times or even indefinitely if you choose Loop).
9. Press Enter or Ctrl-Enter to test.
10. Since the sound can continue to play even after the movie ends or loops it is important to learn also how to stop the sound playing. Insert a keyframe in the Sound Effect layer about half way through the sound’s waveform then select the sound in the frame’s properties then set the Sync property to Stop.
11. Press Enter or Ctrl-Enter to test.
Coming...
In this section I'll explain how you can make a sound play using ActionScript. I'll use ActionScript to play a sound when a button symbol is clicked. Of course, it is also possible to attach sound to a button without using ActionScript as shown in part A above, but using a button is still a simple way of introducing the ActionScript procedures. The important thing to realise is that the procedures below allow you to play sounds anywhere in your ActionScript, such as when a lunar lander crashes, or a player fires a gun, or a slot machine simulator gives a jackpot combination... The assumption is here is that the sound will be very short - this would not be a good method to begin playing background music, for example.
on (release) {
mySound = new Sound(this);
mySound.attachSound("mySound");
mySound.start();
}
As an example, here is a button from Window>Common libraries>Buttons>Classic Buttons>Arcade Buttons. This button, like many of the ready-made buttons, has a 'down state' picture included so that it behaves realistically when clicked. It plays an mp3 sound called 'mySound'.
Sounds can be played anywhere you want in your movie - they don't have to be tied to buttons. For example, you could make an explosion sound play if you crash the lunar lander in the lander project, just as you may have done in Visual Basic. Just put the three key lines above at the right point in your project's ActionScript code.
There are thousands of free MP3 sounds, including special effects and music, available free on the internet. Here are some addresses to get you started.
www.sounddogs.com > sound effects
www.simplythebest.net/sounds/MP3/sound_effects_MP3/index.html for a wide selection of sound effects in mp3 format
music.download.com (more than 70 000 free songs). Please be aware that an MP3 song lasting several minutes can occupy several MB of disk space.