After *appending* a character the caret is positioned after the last
character input pointing to the next position it will accept input.
Hence when you call getLineIndexOfChar(caret) you ask for info about a none
existing character.
This should work:
var tf:TextField = new TextField();
tf.type = TextFieldType.INPUT;
tf.border=true;
tf.multiline = true;
tf.addEventListener(Event.CHANGE, onChange);
addChild(tf);
function onChange(event:Event):void
{
var newCharIndex:int = tf.caretIndex-1;
var line:int = tf.getLineIndexOfChar(newCharIndex);
trace("caretIndex=" + tf.caretIndex + ", newCharIndex=" + newCharIndex
+
", char=" +
tf.text.charAt(newCharIndex).replace(/\r/,"\\r") + ", line=" + line);
}
Cheers, Benny
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders