03-05-2011 01:14 PM
ok, so im trying to add a delay before playing a sound in flex. Reason being i want it to show text then play the sound.
i cant find anything to go with the sound.play()
03-05-2011 01:27 PM
You can do it a couple of ways:
Method 1:
/////////////////////////////////////////
private function ButtonPress( event : Event ) : void
{
var delay :Timer = new Timer( 1000, 1 );
delay.addEventListener( TimerEvent.TIMER_COMPLETE, PlaySound );
delay.start();
}
////////////////////////////////////////////////// ////////
private function PlaySound( event : Event ) : void
{
this.sound.play();
}
OR
setTimeout( PlaySound, 1000 );
.....
private function PlaySound() : void
{
this.sound.play();
}
OR
setTimeout( PlaySound, 1000, sound );
.....
private function PlaySound( sound : Sound ) : void
{
sound.play();
}
03-05-2011 04:14 PM
Or just add some silence to the beginning of your MP3 using a sound editor. Once compressed it will take up virtually no space.
03-05-2011 04:21 PM
03-05-2011 05:01 PM
Try:
var snd:Sound = new Sound(); var ch:SoundChannel = snd.play(); ch.stop();
Obvious you would not call it this way since it will stop right away, but caching the SoundChannel will allow you to stop it before the next play.