0
votes

For some reason, you can't use keyListener.onKeyDown = function() in a class description (says cannot use). Why?

Also, how do i "convert" this into Class.as file usable stuff? *(for example if my class file is called 'Player.as', and it extends MovieClip. And does the extend movieclip make a difference in this problem?)

var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
    if (Key.getCode() == 111) { // a is 65
        //do something
    }
};
Key.addListener(keyListener);
1

1 Answers

0
votes

why is actionscript in stackexchange not supported QQ. Anyway, i don't know the definite answer, but i solved it with this:

if (Key.isDown(111))
    {
        //do something
    }

no getCode()! No listeners! what a relief!