When I create a TextField in AS3 with multiline set to true and equate the text to say:
"Hola \r hola"
I am unable to retrieve the index position of \r using indexOf function, it always returns -1
Does anyone know what I'm doing wrong?
var txt:TextField;
txt.multiline = true;
txt.text = "Hola \r hola";
//txt now renders fine with the line break
trace(txt.indexOf("\r")); //Returns -1, should return the valid index of \r in txt
Following Mikko's answer I gave it a try :
var textField:TextField = addChild(new TextField()) as TextField;
textField.multiline = true;
textField.text = "test \r test";
trace("result>" + textField.text.indexOf("\r"));
This code traces :
result>5
... Just as expected.
If it still doesn't work for you, first try to search for another character than \r, if this works also try to search for \n. Maybe the line feed gets transformed somehow. (which OS are you on?)