开发者

actionscript 2 functions for detecting when no keys are pressed

开发者 https://www.devze.com 2023-03-20 07:11 出处:网络
I开发者_运维百科 would like to know how to detect when no buttons are pressed on a movieclip, such as

I开发者_运维百科 would like to know how to detect when no buttons are pressed on a movieclip, such as

if (no keys are pressed){

this.gotoAndStop("idle"); }


Firstly if you expand your question as you expand your purpose of what you achieve, maybe I can present a more in depth solllution ... ;) I can not imagine why you need a no buttons pressed event. Anyway you can use this code snippet.

//This belongs to no button pressed event.
    var def = 0;
    var keyListener:Object = new Object();
    keyListener.onKeyDown = function() {
       def = 1;
    };
    keyListener.onKeyUp = function() {
       def = 0;
    };
    Key.addListener(keyListener);



//First Part for the whole movie clip
    _root.onEnterFrame = function (){
        trace(def);
        if(def == 1){
        this.gotoAndStop("idle");
        }
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号