现在我试图让键盘事件停止重复。禁用as3中的重复键盘按下事件
我的想法是有一个真实和错误的条件,当按键被按下时,如果键已经关闭,它不会重复。
//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);
}
这样使得按键循环一遍又一遍没有键盘事件 我想我需要添加一个“& &的keyDown ......”到“如果(this.soundplayed ==真)”,但我不知道如何做到这一点没有得到错误
这里是键盘手我试图修复http://soulseekrecords.org/psysci/animation/piano.html
这工作,非常感谢你 – 2010-05-03 14:01:45