Sound in Flash, How to create play onclick button!

Today we learn how to create play on click button in Flash CS3! Here is the final result!
To add some great sound to your Flash movie, you must first import the sound. You can import AIFF, WAV, and MP3 sounds. Flash places these sounds in your Library.
Sounds vary in sample rate, bit rate, and channels. These statistics are important because they affect the quality and size of the sound file. Of course, the length of the sound also affects its size. Here’s what you need to know:
- Sample rate: The number of times the recorder samples an audio signal when it’s recorded in digital form. Measured in kilohertz (kHz). Try not to use more than 22 kHz unless you want CD-quality music.
- Bit rate: The number of bits used for each audio sample. Sometimes called bit resolution. A 16-bit sound file is clearer with less background noise, but use 8-bit sound if you need to reduce file size.
- Channels: Typically one channel of sound (monophonic) or two channels (stereophonic). In most cases, mono is fine for Flash files and uses half the amount of data that stereo uses.
Often, you need to take a sound as you find it unless you have software that can manipulate sounds. Luckily, you can set the specs of sounds when you publish your movie to an .swf file. You generally get the best results by
starting with high-quality sounds and compressing during publishing ( Information from Flash CS3 for Dummies ebook)
Before to start this tutorial you need a sound file, I found a website with free beats ( HERE you can download the beat from my example) and a icon to create a button.

[1] Open Flash CS3 and create a new Flash File (ActionScript 3.0)

[2] Import to Library your sound file and your icon ( File -> Import -> Import to Library )


[2] Put the icon on the stage nad convert it into a Button


[3] Double click on the button to enter inside of it

[4] Now create a new layer for the sound file


[5] Select Layer 1 and on Down layer insert a frame and a keyframe for the Hit Layer


[6] It’s time to put the sound file on the stage. Select the Sound layer and on Down
layer insert a keyframe and a frame for the Hit Layer


Click on the Down layer, go to Library and put the sound in the stage




[7] Test your Movie (Go to Control and select Test Movie)

[8] Now Save your result ( Go to File and select Publish ) and that’s it!

Thank you and you can see the final result here!
Tags: Adobe, Audio, coding, Create Play onclick button, Design, embed, how to, Macromedia Flash, Media, Music in Flash, Sound in Flash CS3, swf, tutorial, webdesign
December 8th, 2007 at 5:19 am
Hi: Each time you click play will run the song (i.e. 4 clicks = 4 times the song concurrently plays). How do you fix this to prevent it from happening? I only want the click to play once no matter how many times someone clicks the button. Thanks!
March 25th, 2008 at 8:28 pm
You can have the play button stop any song before “playing” it:
on(release)
{
_root.snd.stop(); //stops any song
_root.snd.start(0, 10); //play the actual song
}
The author from this tutorial forgot about this same issue: http://www.flash-here.com/tutorials/flash_play_sound.html