Hello everyone o/. I’m working on a game and I’m currently trying to implement a chat input field with little to no success. Since the game will be using characters like “ã”, “ç” and “ó” I was forced to implement it outside of FlashPunk, using some of the tools available from the AS library itself.
I’m using an event listener attached to a TextInput object, set to work with a KeyboardEvent.KEY_DOWN event, calling a function to handle the pressed keys and update the text on the TextInput. The TextInput object itself is a property of an Entity I created to render the text as graphic when the user writes something. Bellow follows the event code:
public function ChatInput(){ //other ChatInput configs sourceText = new TextInput(); sourceText.addEventListener(KeyboardEvent.KEY_DOWN, typeHandle); sourceText.textField.addEventListener(KeyboardEvent.KEY_DOWN, typeHandle); … } function typeHandle(event:KeyboardEvent):void{ trace(“entered here”); doStuff(); }
I added listeners to both the TextInput and its TextField property (read somewhere that the Input had to use some other kind of event? Not sure…), I tested it with a listener only on the TextInput and later on its TextField but it didn’t work either way. I also had them added to the stage AND engine, wondering if that could have been the problem but it was no good, please help D: