I already added a stop button with autoplay but I need to make it so when you click the button again after you had stopped it, the music starts playing.
Source code:
var music:Sound = new Sound(new URLRequest("calmingsong.mp3"));
var sc:SoundChannel = music.play();
button1.addEventListener(MouseEvent.CLICK, stopMusic);
function stopMusic(e:Event):void
{
sc.stop();
}
If you just want to play the sound over from the beginning, just call the
Soundobject’splay()method again (you get a newSoundChannelobject when you do this).If you’d like to resume playing the sound at the point where the user stopped it, you’ll need to add additional variables to store the current “playback state”… Something like this: