我有 2 个电影剪辑。一个角色在行走,另一个角色在奔跑。我如何做到这一点,如果我按左箭头键,它将播放步行剪辑。如果我快速连续按左箭头,它将切换到正在运行的剪辑。我正在使用 Actionscript 3。
问问题
551 次
1 回答
0
This requires a bit of codework as Flash AS3 does not have native support for double clicks. Here is a simple example of how you can achieve this effect with SetTimeout
var keyCodeToListenFor = '13'; // can be any keycode;
var keySinglePress:Boolean = false;
var keyDoublePress:Boolean = false;
var timeToWaitForDoublePress:Number = 400;
var waitingForDoublePress:Boolean = false;
stage.addEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown);
function handleKeyDown(e:Event) {
if (e.keyCode == keyCodeToListenFor) {
keySinglePress = true;
if (waitingForDoublePress) {
keyDoublePress = true;
}
waitingForDoublePress = true;
setTimeout(function() {
waitingForDoublePress = false;
keyDoublePress = false;
}, timeToWaitForDoublePress);
}
if (keyDoublePress) {
trace('You logged a double press!')
} else if (keySinglePress) {
trace('You logged a single press!');
}
}
于 2013-05-15T16:47:11.137 回答