Note :
Words in green are just names and values that you can change them with your own.
Press Ctrl+R to import a sound file, open your library and right-click on it.
Select "Linkage...", "Export this symbol", enter "Loop" in the "Identifier" box and press OK.
Press Ctrl+F8 to make a new movie clip and name it fadeOutMC.
Select the 100th frame of fadeOutMC and press F6 to create a keyframe.
Double-click on it and in the Actions panel enter stop ();
Return to the main timeline.
Double-click on frame 1 and enter the following :
myMusic = new Sound();
myMusic.attachSound("Loop");
myMusic.start( 0, 1000 );
Meaning : We create a new sound object (myMusic), attaching our "Loop" sound and make it play 1000 times.
Select frame 30 and press F6 to create a new keyframe.
Drag fadeOutMC from the library to the stage.
Then select frame 31 and press F6 again.
Double-click on it and in the Actions panel enter stop (); (to prevent the movie from looping in testing mode).
On the stage right-click on fadeOutMC (a small cross) and select "Actions".
Enter the following :
What we do is :
On the 30th frame our fadeOutMC starts playing.
Since it's a movie clip it won't stop at the next frame, but it will play untill it reaches a stop() in its own timeline (the 100th frame).
Then we set a variable (volumeValue) and its value is 100 minus the frame fadeOutMC currently is.
This value decreases as fadeOutMC plays.
Then we set the volume to our sound object to the value of our volumeValue variable.
Test your movie.
After it gets to the 30th frame the music will fade out.
Agamemnon lives in Greece. He is a professional musician (a Double Bass player) and a semiprofessional web author. He loves working with Flash while what hates the most is the incompatibility between browsers.