[AS3] Music Player - Play/Pause
At the moment, I am attempting to make a music player that will play a specific song of my choosing.
I am stuck at the part where you can pause the sound, and then play it in the same place.
I have tried many things such as using the timer utilities.
Right now, when I pause it, it stops, and when I press play, it plays from the beginning.
stop();
var channel:SoundChannel;
var soundCheck:Boolean = true;
var song:Sound = new Sound(new URLRequest("song.mp3"));
channel = song.play();musicPlay.addEventListener(MouseEvent.CLICK, playSong);
function playSong(evt:MouseEvent):void
{
if (!soundCheck)
{
channel = song.play();
}
soundCheck = soundCheck;
}musicPause.addEventListener(MouseEvent.CLICK, pauseSong);
function pauseSong(evt:MouseEvent):void
{
if (soundCheck)
{
channel.stop();
}
soundCheck = !soundCheck;
}