Selteco.com >
FlashDesignerZONE.com >
Tutorials > T1052
Control sound volume with ActionScript.
Click "Play" and then arrows to adjust sound volume:
Minimum Flash Designer version: 5.0.23.2
Download source project t1052.zip (826 kb)
- Launch Flash Designer and set movie dimensions 180 x 180 (or any desired).
- Change frame delay to "Stop".
- Extract "sound1.mp3" file from t1052.zip and import the sound with Movie > Import Sound
- Choose "Frame" > "ActionScript" and paste the code:
mySnd = new Sound();
mySnd.attachSound("sound1.mp3");
volume = 100;
- Choose "Insert" > "Navigation" and insert play, stop, up and down buttons.
- Extract "equalizer.sfd" file from t1052.zip. Choose "Movie" > "Insert Flash Designer Clip" and insert "equalizer.sfd" file. Choose "Item" > "Placement Properties" and check "ActionScript Target"
- Define "OnClick" action for Up arrow:
volume = volume + 10;
if(volume>100) volume = 100;
mySnd.setVolume(volume);
- Define "OnClick" action for Down arrow:
volume = volume - 10;
if(volume<0) volume = 0;
mySnd.setVolume(volume);
- Define "OnClick" action for Play arrow:
mySnd.start(0,100);
equalizer.gotoAndPlay("Frame 2");
- Define "OnClick" action for Stop button:
mySnd.stop();
equalizer.gotoAndPlay("Frame 1");
Hit F9 for preview.