How do I add a sound to a movie?

Playing a sound in a movie is very simple. Use the FSSoundConstructor class to generate the sound definition and then add an instruction to the Flash Player to start playing it.

FSSoundConstructor soundGenerator = new FSSoundConstructor(file);
FSDefineSound sound = soundGenerator.defineSound(identifier);

movie.add(sound);
movie.add(new FSStartSound(new FSSound(identifier, FSSound.Start)));

Slightly confusingly, the FSStartSound is also used to stop a sound once it is playing.

movie.add(new FSStartSound(new FSSound(identifier, FSSound.Stop)));

Here FSSound class is used to simply start and stop a sound however it can also be used to control how a sound is played: defining whether it fades in or fades out, the number of times the sound should be played or even defining an envelope for the sound that can be used to control the volume at any point.