我有一个将此脚本附加到它的动画片段(在悬停时播放声音片段) - 问题是,如果我将鼠标移出,我需要停止声音片段。现在它只是重新开始,而它仍然在播放(鼠标悬停)==不好。在鼠标上停止播放音乐
有没有人有解决方案?我试图做一个MOUSE_OUT
事件和一个.stop();
但它似乎不工作。谢谢!
import flash.media.Sound;
import flash.media.SoundChannel;
//Declare a BeepSnd sound object that loads a library sound.
var BeepSnd:BeepSound = new BeepSound();
var soundControl:SoundChannel = new SoundChannel();
somebutton.addEventListener(MouseEvent.MOUSE_OVER,playNoises);
somebutton.addEventListener(MouseEvent.MOUSE_OUT,stopNoises);
function playNoises(event:Event){
playSound(BeepSnd);
}
function playSound(soundObject:Object) {
var channel:SoundChannel = soundObject.play();
}
function stopNoises(event:Event){
stopSound(BeepSnd);
}
function stopSound(soundObject:Object) {
var channel:SoundChannel = soundObject.stop();
}
我得到这个错误:
TypeError: Error #1006: stop is not a function.
at radio_fla::MainTimeline/stopSound()
at radio_fla::MainTimeline/stopNoises()
你能发布整个代码吗?你在哪里停止声音? – 2011-05-10 13:13:40
这是整个代码 - 没有我阻止它的地方。我需要加入这个。 :-) – janhartmann 2011-05-10 13:14:11
你说你尝试添加一个'MOUSE_OUT'事件和一个'.stop();',如果你发布该代码,也许有人可以告诉你为什么它不起作用 – 2011-05-10 13:16:42