Musik afspiller. Actionscript. Skal kun være muligt at trykke play én gang.
Hej.Prøv at se dette link.
http://vivid-design.dk/masja/Flash/FullMasja.html
Pause, play, og stop -virker fint.
MEN når man trykker play flere gange, overlapper sangene hinanden, og det er ikke muligt at stoppe det hele igen.
Kan I hjælpe mig med, at finde ud af hvad jeg konkret skal skrive i min actionscript for at løse dette problem?
Actionscriptet ser således ud.
SoundMixer.stopAll()
var mySound:Sound = new Sound();
var songURL:URLRequest = new URLRequest("Dreaming.mp3");
var channel1:SoundChannel = new SoundChannel();
var resumeTime:Number = 0;
mySound.load(songURL);
play_btn.addEventListener(MouseEvent.CLICK, playSound);
pause_btn.addEventListener(MouseEvent.CLICK, pauseSound);
stop_btn.addEventListener(MouseEvent.CLICK, stopSound);
function playSound(e:MouseEvent):void {
channel1 = mySound.play(resumeTime)
}
function pauseSound(e:MouseEvent):void {
resumeTime = channel1.position;
channel1.stop();
}
function stopSound(e:MouseEvent):void {
channel1.stop();
resumeTime = 0;
}
var mySound2:Sound = new Sound();
var songURL2:URLRequest = new URLRequest("WingsOfAnEagle.mp3");
var channel2:SoundChannel = new SoundChannel();
var resumeTime2:Number = 0;
mySound2.load(songURL2);
play_btn2.addEventListener(MouseEvent.CLICK, playSound2);
pause_btn2.addEventListener(MouseEvent.CLICK, pauseSound2);
stop_btn2.addEventListener(MouseEvent.CLICK, stopSound2);
function playSound2(e:MouseEvent):void {
channel2 = mySound2.play(resumeTime)
}
function pauseSound2(e:MouseEvent):void {
resumeTime = channel2.position;
channel2.stop();
}
function stopSound2(e:MouseEvent):void {
channel2.stop();
resumeTime = 0;
}
var mySound3:Sound = new Sound();
var songURL3:URLRequest = new URLRequest("FragilenYoung.mp3");
var channel3:SoundChannel = new SoundChannel();
var resumeTime3:Number = 0;
mySound3.load(songURL3);
play_btn3.addEventListener(MouseEvent.CLICK, playSound3);
pause_btn3.addEventListener(MouseEvent.CLICK, pauseSound3);
stop_btn3.addEventListener(MouseEvent.CLICK, stopSound3);
function playSound3(e:MouseEvent):void {
channel3 = mySound3.play(resumeTime)
}
function pauseSound3(e:MouseEvent):void {
resumeTime = channel3.position;
channel3.stop();
}
function stopSound3(e:MouseEvent):void {
channel3.stop();
resumeTime = 0;
}
var mySound4:Sound = new Sound();
var songURL4:URLRequest = new URLRequest("InLove.mp3");
var channel4:SoundChannel = new SoundChannel();
var resumeTime4:Number = 0;
mySound4.load(songURL4);
play_btn4.addEventListener(MouseEvent.CLICK, playSound4);
pause_btn4.addEventListener(MouseEvent.CLICK, pauseSound4);
stop_btn4.addEventListener(MouseEvent.CLICK, stopSound4);
function playSound4(e:MouseEvent):void {
channel4 = mySound4.play(resumeTime)
}
function pauseSound4(e:MouseEvent):void {
resumeTime = channel4.position;
channel4.stop();
}
function stopSound4(e:MouseEvent):void {
channel4.stop();
resumeTime = 0;
}
buy_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage_2);
function fl_ClickToGoToWebPage_2(event:MouseEvent):void
{
navigateToURL(new URLRequest("http://www.gdc.dk/enduser/shop.aml?shop=4157498"), "_blank");
}