Well... There are different types of listeners, and I'm not very familiar with them all. But I like using the key listener when I need my movie to detect a key hit. It's beneficial in some cases, because you don't need to put your code under an onEnterFrame even handler for it to take effect. The code is only called when a keyboard key is hit, which saves on system resources since the code isn't being checked every frame.
So instead of using the following code, where the if() statement is constently being checked...
Code:
onEnterFrame = function () {
trace("checking");
if (Key.isDown(65)) {
trace("You hit the \"a\" key!");
}
};
...You can use this code, where it is only checked on when a key is hit.
Code:
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
trace("checking");
if (Key.isDown(65)) {
trace("You hit the \"a\" key!");
}
};
Key.addListener(keyListener);