hi guys
i have problem with making a button to play/stop music using the code snippets
first i imported a music file with mb3 format to the library then i dragged a button from the components panal
the thing is i want to make a button that when i hit it once the music starts and when i hit it again it stops
so, i went to code snippets i choose audio and video then i choose click to play/stop sound
and this is the actionscript
/* Click to Play/Stop Sound
Clicking on the symbol instance plays the specified sound.
Clicking on the symbol instance a second time stops the sound.
Instructions:
1. Replace "http://www.helpexamples.com/flash/sound/song1.mp3" below with the desired URL address of your sound file. Keep the quotation marks ("").
*/
btn.addEventListener(MouseEvent.CLICK, fl_ClickToPlayStopSound_5);
var fl_SC_5:SoundChannel;
//This variable keeps track of whether you want to play or stop the sound
var fl_ToPlay_5:Boolean = true;
function fl_ClickToPlayStopSound_5(evt:MouseEvent):void
{
if(fl_ToPlay_5)
{
var s:Sound = new Sound(new URLRequest("http://www.helpexamples.com/flash/sound/song1.mp3"));
fl_SC_5 = s.play();
}
else
{
fl_SC_5.stop();
}
fl_ToPlay_5 = !fl_ToPlay_5;
}
anyway in the instructions it says that i should replace the url with the music file but i have it in the library
not as url how can i put it in the actionscript without making errors cus i tried it hundreds of time and im
trying this for a month and it always has error .
im about to get mad so pleeeese pleeeeeeese help meee.
Whether you import an mp3 or a wav file is irrelevent. Be sure to compress your audio file to the smallest useful size. Here's an example file that does what you're looking to do: http://www.ddg-designs.com/downloads/internalSound.zip
North America
Europe, Middle East and Africa
Asia Pacific