Help pls. (mp3 using flash)
Im not really familiar with adobe flash and especially coding.so pls bear with me T.T
i managed to search for a working code for pause/start/play buttons for my mp3.
here is the code:
stop();
var mySound:Sound;
var myChannel:SoundChannel;
var soundIsPlaying:Boolean = false; //prevent play btn overlap
var p:uint = 0;
mySound = new Sound;
mySound.load(new URLRequest("Fall Out Boy - Beat It ft. John Mayer.mp3"));
btn_play.addEventListener(MouseEvent.CLICK, playSound);
btn_stop.addEventListener(MouseEvent.CLICK, stopSound);
btn_pause.addEventListener(MouseEvent.CLICK, pauseSound);
function stopSound(myEvent:MouseEvent):void {
myChannel.stop();
p = 0;
soundIsPlaying = false;
}
function playSound(myEvent:MouseEvent):void {
if (!soundIsPlaying) {
myChannel = mySound.play(p); //play song location (p)
soundIsPlaying = true;
}
}
function pauseSound(myEvent:MouseEvent):void {
if (soundIsPlaying) {
p = Math.floor(myChannel.position);
myChannel.stop();
soundIsPlaying = false;
}
}
//prev and next buttons//
btn_next.addEventListener(MouseEvent.CLICK, MightWork);
function MightWork(event:MouseEvent):void
{
nextFrame();
}
btn_prev.addEventListener(MouseEvent.CLICK, MightNot);
function MightNot(event:MouseEvent):void
{
prevFrame();
}
im going to make five frames, with five different songs on the action script. but when i press previous or next button. my songs would overlap each other...
"SoundMixer.stopAll()" wont work for me... pls help.