0

我可以描述这一点的唯一方法是显示我已经拥有的代码,然后尝试解释我想要做什么。基本上,我正在创建一个音板游戏,在屏幕底部我将有一个作为电影剪辑的栏,然后我将把其他影片剪辑拖到上面,然后单击付款,然后使用数组和 .push 将它们按顺序播放。我正在尝试使用代码将声音放到影片剪辑上。到目前为止,我有这个:

var snd1:Sound = newSound();
snd.load(newURLRequest("naturefrog.wav"));

var channel:SoundChannel;
snd.addEventListener

我现在坚持要让听众听的内容。

4

3 回答 3

0

您应该使用Flash API for Sound来确定要添加的侦听器。页面底部有一些有用的示例。

我假设您要添加:

snd.addEventListener(Event.COMPLETE, completeHandler);
snd.addEventListener(Event.ID3, id3Handler);
snd.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
snd.addEventListener(ProgressEvent.PROGRESS, progressHandler);
于 2011-04-01T16:19:24.180 回答
0

如果声音是外部的,请参阅此答案以了解声音何时完成加载: 从外部源加载声音

现在,一旦您准备好播放声音并听它何时完成,这里就可以回答: 演示为 sound_complete 设置侦听器以及循环

于 2011-04-01T17:55:27.023 回答
0

当用户将影片剪辑的声音引用拖入特定的影片剪辑时,您将其推送到数组中,对吗?如果这样做,您可以从数组中移动一个元素(array.shift,通常这会删除并返回数组的第一个元素)。

function playSoundInArray(){
    if(array.length){
        var snd:Sound = array.shift() as Sound;
        channel = snd.play();
        channel.addEventListener(Event.SOUND_COMPLETE, onSoundPlayed);
    }else{
        //Do something here if there is no sound reference or the array is empty
    }
}

function onSoundPlayed(e:EVent){
    channel.removeEventListener(Event.SOUND_COMPLETE, onSoundPlayed);
    playSoundInArray();
}
于 2012-09-13T07:55:04.290 回答