Adding sounds to a movie
To add a sound to a movie from the library, you assign the sound to a layer and set options in the Sound controls in the Property inspector. It is recommended that you place each sound on a separate layer.
To test sounds that you add to a movie, you can use the same methods you use to preview frames or test movies: drag the playhead over the frames containing the sound, or use commands in the Controller or the Control menu.
For more consult the Macromedia Flash Help or Macromedia PDF Documentation available at:
http://macromedia.com/devnet/
Adding sounds dynamically (from an external file)
We construct a mini player for control the sound
Open a new flash file
Establish the document property to 300pxX300px;
With text tool select the font “Webdings” size 24 (or more) type an “X” (with “CapsLock” activated). Will appears a speaker Convert it to MovieClip.
Check the box “Export for ActionScript” at get the identifier “speaker”.
Type the same name in the Property field <Instance Name>.
On the new layer above this in the same place type with the text tool a lowercase “x”. Will obtain the interdiction sign.
Check the box “Export for ActionScript” at get the identifier “speaker”.
Type the same name in the Property field <Instance Name>.
Introduce also the three movie clips a bar bellow themovie clip “speaker” and get it the identifier and the instance name “scale” and two MovieClips plus and minus with plus and minus identifier and instance name.
Create a layer named “as” and in this first and only frame write the next code:
this._lockroot=true; // establish the root for the external swf (available in Flash 2004);* mute=false; //initialize the volume* _soundbuffertime=100;//establish the sound buffer to 100s* no_sound._visible=false;// hide the movieclip "no_sounnd"* volume=75; // set the volume to 75%* vd=0;// vd(volume direction) variable indicate that volume increase or decrease* var music=new Sound();// create the new Sound Object* music.loadSound("music.mp3",true);// the external mp3 file is loaded* music.start()// start the audition* // a function is attached to the movieclip _root With it we assure that the volume increase or decrease in function of the vd value.* //Also, the movieclip scale is resized to the appropriate value* _root.onEnterFrame=function(){ if(!mute){ if(((vd>0)&& (volume0))){ volume+=vd; music.setVolume(volume); scale._xscale=volume} } } // when the movieclip "speaker" is clicked the volume was muted and the movieclip "no_sound".apears* // the next function is attached to the clip "speaker"* speaker.onRelease=function(){ _root.mute=!_root.mute; // balance between the two situation the sound is muted or not* if(_root.mute){_root.no_sound._visible=true; _root.music.setVolume(0);} else{ _root.no_sound._visible=false; _root.music.setVolume(volume)} } //The movieclips plus and minus are clicked for increase or decrease the volume* //for this:* plus.onRollOver=function(){ vd=2; } plus.onRollOut=function(){ vd=-0; } minus.onRollOver=function(){ vd=-2; } plus.onRollOut=function(){ vd=-0; }
Test the movie and save it as “sound swf”.
For adding this file to an other flash file in this target file create a n empty movie clip named “music” and on the “as” layer write:
_root.attachMovie("music", "music", 1000);
_root.music.loadMovie("sound swf");// load the external file*
// position the container movieclip "music" on the Stage(the values can be changed and adapted to a specific file)*
_root._x=620;
_root._y=20;
_root._xscale=75;
_root._yscale=75;









