我正在努力使用闪存文件,我想在按下相应的按钮时播放两个不同的声音文件。 我已经把它加载到没有任何错误弹出的位置,但是当我按下该声音的按钮而不是播放第二个声音时,它再次播放第一个声音。 这是代码:
var sc1:SoundChannel = new SoundChannel();
var s1:Sound = new Sound();
s1.load(new URLRequest("http://www.website.com/wells.mp3"));
wellsplay_btn.addEventListener(MouseEvent.CLICK,playSound);
wellsstop_btn.addEventListener(MouseEvent.CLICK,stopSound);
function playSound(e:MouseEvent):void
{
sc1 = s1.play();
}
function stopSound(e:MouseEvent):void
{
sc1.stop();
}
var sc2:SoundChannel = new SoundChannel();
var s2:Sound = new Sound();
s2.load(new URLRequest("http://www.website.com/waves.mp3"));
wavesplay_btn.addEventListener(MouseEvent.CLICK,playSound);
wavesstop_btn.addEventListener(MouseEvent.CLICK,stopSound);
function playSound2(e:MouseEvent):void
{
sc2 = s2.play();
}
function stopSound2(e:MouseEvent):void
{
sc2.stop();
}
我很感激任何建议。
答案 0 :(得分:0)
wavesplay_btn.addEventListener(MouseEvent.CLICK,playSound2);
wavesstop_btn.addEventListener(MouseEvent.CLICK,stopSound2);