如何制作具有不同声音的2个按钮(FLASH动作脚本)

时间:2016-01-29 03:57:09

标签: flash

我正在尝试制作两个不同声音的按钮(然后更多)。我有创建的按钮和库中的声音,但似乎我的动作代码不起作用。如果我只使用第一段,我会在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();
};

1 个答案:

答案 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();
};