Hi guys,
I'm trying to change this as2 code to as3...
Actionscript Code:
myText.onChanged = function() {
trace("CHANGED!");
trace("THIS WAS PRESSED: " + String.fromCharCode(Key.getAscii()))
}
I've tried the following - but it is no good if the user pastes or cuts text using the mouse:
Actionscript Code:
myText.addEventListener(KeyboardEvent.KEY_UP, setText);
I've also tried TextEvent.TEXT_INPUT -- both KeyboardEvent and TextEvent let me get the users input -- but the problem is the textfield is updated after the listener function is run.
This is no good - as the function is making a change to the users input.
The only way i found to detect if the textfield has been changed (which also works if the user pastes, or cuts with the mouse) is the following:
Actionscript Code:
myText.addEventListener(Event.CHANGE, setText);
function setText (e:Event):void {
trace("CHANGED")
trace("BUT THIS IS THE FULL TEXT " + e.target.text)
}
But i need to get the single key the user pressed on the keyboard - like in my AS2 example. I'm kind of looking for a e.keyCode that works with an EVENT, not just a Keyboard or Text event.
Thanks for any help!