I am using a text box and i added an event listener on key down.I want to know the last typed character with the help of charCode(or any thing which is poosible). Main problem is that when I want to press '(' i.e right parentheses then i am unable to find typed character. All these things are in flex.So anyone??
+1
A:
How about this:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" applicationComplete="onComplete();">
<mx:Script><![CDATA[
import flash.events.TextEvent;
private function onComplete():void
{
textInput.addEventListener(TextEvent.TEXT_INPUT, onTextInput);
}
private function onTextInput(e:TextEvent):void
{
var lastChar:String = e.text.charAt(e.text.length - 1);
if (lastChar == ")")
typed.text = "Right parentheses!!!";
else
typed.text = lastChar;
}
]]></mx:Script>
<mx:TextInput id="textInput"></mx:TextInput>
<mx:Label id="typed"></mx:Label>
</mx:Application>
mauvo
2010-03-22 14:36:59