Hey guys, I just have a quick query that is going to help me in the not too distant future, but firstly i wanted to check that what i want is actually possible within AS3, im sure it is…
i couldnt attach my demo, its basically two buttons on stage, that play two seperate sound files, they can be turned on and off by a simple boolean.
All songs are short sound files (going to be 10 second loops)
What i want to know is, is there anyway to not start either of the sounds until the other one has finished its loop, so they are synchronised, so if i start one button off, and then put button 2 on midway through, it actually waits until buttons 1 sound is back at the start of its loop cycle until it starts to play it.
If this is possible then i am excited as i am going to make a small little project
import flash.events.MouseEvent;
var firstSound:Sound1 = new Sound1();
var secondSound:Sound2 = new Sound2();
var channel1:SoundChannel;
var channel2:SoundChannel;
var soundTrans1:SoundTransform = new SoundTransform(1,0);
var soundTrans2:SoundTransform = new SoundTransform(1,0);
var button1On:Boolean = false;
var button2On:Boolean = false;
button1.addEventListener(MouseEvent.CLICK, buttonSelected);
button2.addEventListener(MouseEvent.CLICK, buttonTwoSelected);
function buttonSelected (event:MouseEvent):void{
if (button1On == false){
button1On = true;
channel1 = firstSound.play(0,9);
channel1.soundTransform = soundTrans1;
button1.alpha = 0.7;
} else if (button1On == true){
button1.alpha = 1.0;
channel1.stop();
button1On = false;
}
}
function buttonTwoSelected (event:MouseEvent):void{
if (button2On == false){
button2On = true;
channel2 = secondSound.play(0,9);
channel2.soundTransform = soundTrans1;
button2.alpha = 0.7;
} else if (button2On == true){
button2.alpha = 1.0;
channel2.stop();
button2On = false;
}
}
p.s snickelfritz, if you view this, i have started working my way through the tutorials and already understand so much more about the basic concepts of AS3, thank you so much.
Thanks a lot for looking.
Chris