嗨,我对 actionscript 真的很陌生,我在播放声音时遇到了问题。当我松开向上键时,我希望我的声音停止播放。我设法让声音在按键时播放。
这是我的代码...
import flash.events.KeyboardEvent;
var mySound:Sound = new carstart();
stage.addEventListener(KeyboardEvent.KEY_DOWN, playSound);
stage.addEventListener(KeyboardEvent.KEY_UP, stopSound);
function playSound(keyEvent:KeyboardEvent) {
if (keyEvent.keyCode == 38) {
mySound.play();
}
}
function stopSound(keyEvent:KeyboardEvent) {
if (keyEvent.keyCode == 38) {
mySound.stop();
}
}
我得到这个错误
Scene 1, Layer 'Actions', Frame 1, Line 29 1061: Call to a possibly undefined method stop through a reference with static type flash.media:Sound.
如果您能想到任何事情,那将是一个很大的帮助。
谢谢