Adding a key listener in Action Script 3
问题 I am relatively new to Action Script, and I am trying to make a game of Snake. Obviously I need to implement a global key listener, but I am having odd problems. I tried adding the listener to the application tag but it didn't seem to have any effect (the movie was still able to compile). Whenever I call this.stage.addEventListener(KeyboardEvent.KEY_DOWN, key, true); my program crashes. Below is the content of my main.mxml file: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx=