0

这是我的问题

在我的主舞台上,我添加了这段代码以进行声音重复,它在这个舞台上运行良好并且循环良好

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();

但是,我已将代码添加到另一个页面(并更改了所有变量)并且正确的声音播放一次正确,但是,当它应该循环播放第一阶段的声音时。(第二页代码如下所示)

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();

所以它在重复播放声音 playSound2 它播放 playSound

任何帮助将不胜感激谢谢

4

1 回答 1

1

您忘记更改onCompleteonComplete2

Crow_channel.addEventListener(Event.SOUND_COMPLETE, onComplete);
SoundChannel(event.target).removeEventListener(event.type, onComplete);

他们应该是:

Crow_channel.addEventListener(Event.SOUND_COMPLETE, onComplete2);
SoundChannel(event.target).removeEventListener(event.type, onComplete2);
于 2012-12-23T04:19:40.767 回答