现在我正试图让键盘事件停止重复。
我的想法是当按键被按下时有一个真假条件,这样如果按键已经按下,它就不会重复。
//Mouse Event Over
keyCButton.addEventListener(MouseEvent.MOUSE_OVER, function(){gotoAndStop(2)});
//Variable
var Qkey:uint = 81;
//Key Down Event
stage.addEventListener(KeyboardEvent.KEY_DOWN, keydown);
var soundplayed = false;
function keydown(event:KeyboardEvent){
if (event.keyCode==Qkey) {
this.soundplayed=true;
}
}
if (this.soundplayed==false){
gotoAndPlay(3);
}
//Key Up Event
stage.addEventListener(KeyboardEvent.KEY_UP, keyup);
function keyup(event:KeyboardEvent){
this.soundplayed=false;
gotoAndStop(1);
}
这样做会使键循环一遍又一遍而没有键盘事件我想我需要在“if (this.soundplayed==true)”中添加一个“&& keyDown ...”但我不知道如何在没有错误的情况下做到这一点
这是我要修复的键盘手http://soulseekrecords.org/psysci/animation/piano.html