View Full Version : keyboardevent listener
hakukaji
September 10th, 2007, 09:35 AM
I would like to make a generic keyboardevent listener, or place a keyboardeven listener method in a class, but every time i do this it doesn't seem to work. I can only get it to work in my main class.
Maqrkk
September 10th, 2007, 02:31 PM
What is it that doesn't work? Make sure to add the EventListener to the stage, and not an object, although this might depend on how you are going to use it.
hakukaji
September 10th, 2007, 03:55 PM
ive got a Player object and keyDownListener method in the Player class, should i put
stage.addEventListener(KeyboardEvent.KEY_DOWN,keyD ownListener);
in the constructor?
i think im just having a tough time deciding when to put listeners in the classes themselves or the main class
Maqrkk
September 10th, 2007, 04:16 PM
I don't see any problems with that code. Think it should work. I'm also not 100% where to put it. I just experiment and see what works best, and easiest.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.