hello, I’ve been spending a couple of days and many hours trying to get this 1 last thing for my website. My knowledge in AS3 is very very limited, I’m mainly an illustrator, so i’m hoping you guys can help me out with this.
I’m building a flash site with an animation that loops, and i’ve added an mp3 song as background music that is set to auto play. the problem is since the song is longer than the animation, when the animation goes back to frame one, the song stacks ontop of the one still playing , and the play and pause buttons start only working for the stacked song and not the other. I want the song to loop, but start playing only after it finishes the first time.
Here is the code so far:
import flash.events.MouseEvent;
import flash.media.Sound;
import flash.net.URLRequest;
//var codes
var AutoPlay:Boolean=true;
var isPlaying:Boolean=false;
var pausePosition:Number=0;
var myMusic:Sound=new Sound();
var soundFile:URLRequest=new URLRequest(“Fluke.mp3”);
myMusic.load(soundFile);
var channel:SoundChannel;
//if commands
if (AutoPlay==true) {
channel=myMusic.play(pausePosition);
isPlaying=true;
}
//pausebutton functions
pause_btn.addEventListener(MouseEvent.CLICK, pauseSound);
function pauseSound(e:MouseEvent):void
{
if (isPlaying == false) {
channel = myMusic.play(pausePosition);
isPlaying =true;
}else{
pausePosition=channel.position;
channel.stop();
isPlaying=false;
}
}
//playbutton functions
play_btn.addEventListener(MouseEvent.CLICK,playMus ic);