【发布时间】:2012-03-20 18:51:17
【问题描述】:
这是在 Flash CS5.5 中编程的:
我想按下一个按钮,一次播放整个数组的一个声音。当第一个声音停止时,第二个声音开始,依此类推,直到最后一个声音播放。当最后一个声音结束时,所有声音都应该停止,如果再次按下播放按钮,它应该从头开始,并重新播放所有声音。
目前,要前进到下一个声音,您必须再次按下按钮。我认为需要使用 SOUND_COMPLETE ...我只是不确定如何使用,因此是空函数。我只想按一次播放来按顺序听到整个阵列。有什么想法吗?
var count;
var songList:Array = new Array("test1.mp3","test2.mp3","test3.mp3");
count = songList.length;
myTI.text = count;
var currentSongId:Number = 0;
playBtn.addEventListener(MouseEvent.CLICK, playSound);
function playSound(e:MouseEvent):void{
if(currentSongId < songList.length)
{
var mySoundURL:URLRequest = new URLRequest(songList[currentSongId]);
var mySound:Sound = new Sound();
mySound.load(mySoundURL);
var mySoundChannel:SoundChannel = new SoundChannel();
mySoundChannel = mySound.play();
currentSongId++;
mySoundChannel.addEventListener(Event.SOUND_COMPLETE,handleSoundComplete)
}
if(currentSongId == songList.length)
{
currentSongId = 0;
}
}
function handleSoundComplete(event:Event){
}
【问题讨论】:
标签: actionscript-3 flash actionscript