Hello!
How can I control sound in flash so that:
- the music starts when the user clicks on a play button but when they click on the play button again while the music is playing, the music DOESN’T overlap??
- the music doesn’t overlap when going back to the homepage where the music first started playing??
I’m currently using the code below but the music overlaps when I press the play button more than once while the music is playing and when I go back to the page where the music started playing…:o
var mySound:Sound = new Sound();
var myChannel:SoundChannel = new SoundChannel();
var lastPosition:Number = 0; // pause button
mySound.load(new URLRequest("that_tune.mp3"));
//mySound.play();
myChannel = mySound.play();
stop_but.addEventListener(MouseEvent.CLICK, onClickStop);
function onClickStop(e:MouseEvent):void{
myChannel.stop();
}
pause_but.addEventListener(MouseEvent.CLICK, onClickPause);
function onClickPause(e:MouseEvent):void{
lastPosition = myChannel.position;
myChannel.stop();
}
play_but.addEventListener(MouseEvent.CLICK, onClickPlay);
function onClickPlay(e:MouseEvent):void{
myChannel = mySound.play(lastPosition);
}
I appreciate any help you can give me!!