我想知道是否有人可以帮助我在Flash动作。循环声音actionscript闪光灯
我希望有一些不同的按钮,当我点击按钮时播放不同的声音循环,但是当其他音乐旋律完成时,每个循环都必须启动。谁能帮我?
谢谢
邓丽君
我想知道是否有人可以帮助我在Flash动作。循环声音actionscript闪光灯
我希望有一些不同的按钮,当我点击按钮时播放不同的声音循环,但是当其他音乐旋律完成时,每个循环都必须启动。谁能帮我?
谢谢
邓丽君
通过使用AS3 SoundChannel类,你可以得到的addEventListener - Event.SOUND_COMPLETE,将通知您的声音完整的,然后你可以玩下声音
嗯,我假设你想播放与最后一个按钮相关的声音,而不是一起播放很多声音。
所以,你有你改变按钮按下全局声音变量
var sound:Sound=new Sound(new URLRequest("music.mp3"));
var soundChannel:SoundChannel=new SoundChannel();
soundChannel=sound.play();
soundChannel.addEventListener(Event.SOUND_COMPLETE,loop_Sound);
function loop_Sound(e:Event){
soundChannel=sound.play();
//I know you don't need to add the listener again to the sound channel
//but this is something i just do
soundChannel.addEventListener(Event.SOUND_COMPLETE,loop_Sound);
}
//call this function when the button is pressed
//you could name the button name as the sound file's name
//and use e.currenttarget.name or something
function change_Sound(e:MouseEvent){
sound=new Sound(new URLRequest("music2.mp3"));
}
当按下按钮这将加载声音,但只有当你当前的声音播放完,如果按钮没有发挥它在播放时按下它会循环播放当前的声音。祝好运!