Here’s my question
On my Main Stage I added this code to have a sound repeat, it works fine on this stage and loops well
var HP1sound:Sound = new HP_sound();
var HP_channel:SoundChannel = new SoundChannel();
function playSound():void
{
HP_channel=HP1sound.play();
HP_channel.addEventListener(Event.SOUND_COMPLETE, onComplete);
}
function onComplete(event:Event):void
{
SoundChannel(event.target).removeEventListener(event.type, onComplete);
playSound();
}
playSound();
However, I have added the code to another page (and changed all the variables) and the correct sound plays one time correctly, however, when it should loop it plays the first stage’s sound. (2nd page code shown below)
var Crow_sound2:Sound = new Crow_sound();
var Crow_channel:SoundChannel = new SoundChannel();
function playSound2():void
{
Crow_channel=Crow_sound2.play();
Crow_channel.addEventListener(Event.SOUND_COMPLETE, onComplete);
}
function onComplete2(event:Event):void
{
SoundChannel(event.target).removeEventListener(event.type, onComplete);
playSound2();
}
playSound2();
So it’s playing sound playSound2 on the repeat it plays playSound
any help would be appreciated thank you
You forgot to change
onCompletetoonComplete2on these lines:They should be: