This tutorial helps you to create a simple flash button that will provide the music ON/OFF property. For this you need to have a basic knowledge of flash about how to create symbols, creating tweening effects. You may also need to know the basics of flash actionscript because this tutorial uses flash action script to create sound on-off button in FlashMX 2004.Anyone who hasn’t have a knowledge about them could refer our flash tutorials. For tutorials on Dreamweaver, Fireworks and Photoshop visit our tutorial page.
For viewing the animations in this site you need to install Flash Player 7.0 or higher and for downloading the .fla files from this site FlashMX 2004 must be installed in your system.
Creating sound on-off button
You have to create two buttons and two movieclip. One button is for ON and the other is for OFF. The two movieclip are for buttons and symbols respectively.
Now create three keyframes and insert stop action to all the keyframes. In the first keyframe insert your music. It should be noted that the music’s loop count must be fairly high and the sync should be an event.
Insert the below actionscript code in frame 2
gotoAndStop(1);
Insert the below actionscript code in frame 3
gotoAndPlay(1);
After these steps you will get a Sound movie clip.
We have to create the button movie clip. For this purpose follow the steps below.
Create two keyframes and insert stop actions to both the keyframes. Also insert the OFF button into frame 1 and ON button in frame 2.
By selecting the OFF button insert the following actionscript in the actionscript panel.
on (release) {
tellTarget ("../music") {
stopAllSounds();
}
}
on (release) {
nextFrame();
}
By selecting the on button insert the following actionscript in the actionscript panel.
on (release) {
tellTarget ("../music") {
nextFrame();
}
}
on (release) {
prevFrame();
}
Add the created Sound movie clip into the movie and give an instance name to it. Also add the button movie clip to the movie.
You have finished creating the sound ON-OFF button. Press Ctrl+Enter to view the movie you created.ll