Loop sound in each background
Someone helped me last time with my sounds. Now, when my player enters in a scene, a new sound starts (and the sound of the previous background stops).
But now I can't find a way to loop the sound in each background...I'm trying to use
public function playSound():void{
channel = music.play();
channel.soundTransform = transformer;
channel.addEventListener(Event.SOUND_COMPLETE, loopSound, false, 0, true);
}
private function loopSound(e:Event):void{
channel.removeEventListener(Event.SOUND_COMPLETE, loopSound);
playSound();
}
But it doesn't seem to work. In fact, I don't really know when should I call this function.
I've got a quite simple code :
public var currentSoundChannel:SoundChannel;
public function newBackground(thisBack:String):void
{
var room = back.currentBack;
if (currentSoundChannel != null)
{
currentSoundChannel.stop()
}
var nextSong:Sound;
switch (thisBack){
case "maisonExt":
nextSong = new exterieur ();
break;
case "garage":
nextSong = new mouche ();
break;
case "monde":
nextSong = new cartesnd();
break;
}
currentSoundChannel = nextSong.play();
}
So, where should I put my loopsound function ?
Thank you very much !
