我正在尝试制作两个不同声音的按钮(然后更多)。我有创建的按钮和库中的声音,但似乎我的动作代码不起作用。如果我只使用第一段,我会在key16按钮上播放声音16。但是当我添加第二个(重复和修改的)密钥17代码时,没有任何反应:
key16.addEventListener(MouseEvent.CLICK, playSound);
function playSound(event:Event) {
var mySound:sound16 = new sound16();
var myChannel:SoundChannel = mySound.play();
};
key17.addEventListener(MouseEvent.CLICK, playSound);
function playSound(event:Event) {
var mySound:sound17 = new sound17();
var myChannel:SoundChannel = mySound.play();
};
答案 0 :(得分:0)
这有效:
key16.addEventListener(MouseEvent.CLICK, playSound1);
function playSound1(event:Event) {
var mySound1:sound16 = new sound16();
var myChannel1:SoundChannel = mySound1.play();
};
key17.addEventListener(MouseEvent.CLICK, playSound2);
function playSound2(event:Event) {
var mySound2:sound17 = new sound17();
var myChannel2:SoundChannel = mySound2.play();
};