This article or chapter is incomplete and its contents need further attention.
Some information may be missing or may be wrong, spelling and grammar may have to be improved, use your judgment!
This tutorial is outdated. It was made for (older) CS3
This text should technical people get going and may not be good enough for self-learning beginners. It can be used as handout in a "hands-on" class. That is what Daniel K. Schneider made it for...
Level
It aims at beginners. More advanced features and tricks are not explained here.
Step 1 - Create a new layer and import sound to a frame
You can attach sound to any frame via the properties panel
Create a new layer for this sound
Insert a keyframe (F7) where you want the sound to start
Select a sound from the sound pull-down menu in the properties panel.
Configure it in the same panel (see next)
Ideally, each sound should have its own layer. This way it is much easier to control fade in/outs, when to stop etc. You also can see exactly how far the sound will extend on the timeline. Hit F5 or F7 (if you want to stop the sound) somewhere to the right.
Flash sound layers
Step 2 - Configuration of sounds
In the configuration panel you can change certain parameters and also edit a bit.
Sync: Will defined how sound is synchronized with the timeline.
Event: Sound plays until it is done (independently of the rest). It has its own "timeline". Also, if this sound is triggered again (e.g. a user enters the same frame), a new sound will play even if the old one is not over.
Start: Similar as event. Will play the sound when the frame loads but will not play it if the old sound is still playing. Note: This doesn't always work as expected. Probably best to use together with the Stop (see below).
Stop : Will stop the sound of a layer at this frame (therefore include it after a sound frame). Insert a new keyframe (F7) where you want it to stop and just edit the properties.
Stream: Will try to match the length of sound with the other layers, e.g. 20 frames of sound should play during animation of 20 frames. After that it should stop. Sound as stream should not be looped. Use this for example for comic strips (talking characters).
Repeat:
You can repeat the sound as many times as you like (or even have it loop forever).
Effect:
You can choose from various fade in/out and left/right options, but you probably want to do your own custom fades (see next).
Click in the sound layer in some frame where you have sound
In the Properties Panel, Click the Edit ... button next to the Effect: field
This opens the Edit Envelope editor.
Manipulation of the sound envelope
You can drag left/right Time In and Time Out controls in middle pane. I.e. you can cut off sound from the either the beginning or the end of the sound track.
You can drag down volume controls (black lines on top) for the left and the right stereo channel
Click to insert a new distortion point for these volume controls
Up: means louder / maximum sound
Down: means more silent / no sound
Use the arrow (down left) to test
At bottom right there are zoom buttons and a switch that either shows seconds or frames.
You can look at my published animation with sound example. It shows a motion animation with a global music sound track and 4 layers with sound "textures" that are limited in time.
It is better to load sounds with ActionScript if your sound file is large, e.g. a background music or if you want to to trigger a sound as a result of some complex user interaction.
Embedded ActionScript 3
Insert this kind of code with F9 in the frame where you want if to load. Typically, use a frame in a layer called "action" or "script".
To load a sound from an external file:
var request:URLRequest = new URLRequest("track.mp3");
var your_sound:Sound = new Sound();
your_sound.load(request);
Alternatively, to load a sound from the library:
Export the sound for ActionScript 3:
Right click on the sound in the library, select properties
Click on Advanced
Tick Export for ActionScript
Define the classname, e.g name class for a file called "noise.mp3" something like "Noise_sound".
Then create a new sound from this class (just this single line)
var cool_noise_sound:Sound = new Noise_sound();
To play your sounds:
your_sound.play();
cool_noise_sound.play ();
To play 5 loops:
your_sound.play(0,5);
To stop all sounds (this is a static method, just insert the line as is).
For a button on and off:
select the symbol which is aimed to be the button, in the frame where the on / off has to happen. Select the code snippet "click to play/stop sound" in the audio and video category. Give an occurrence name to your symbol and target your soundfile name instead of the flash example. For the sound to stop in the other frames, you can use the following action script in the frames you want the sound to be stopped.