It looks like the force update method you need for TextArea is validateProperties(). I forget if you're going to need to do more to get the internal textField to update. We'll cross the bridge later if we need to.
- Dan Freiman On 10/28/07, jamalwally <[EMAIL PROTECTED]> wrote: > > Hi, > > I can't get the correct information about line numbers in the text of > a custom class that extends TextArea (call it MyTextArea). > > If I set the text property of the TextArea in onCreationComplete() > then getLineIndexAtPoint() returns -1. > > I imagine that after I update the text property, I must wait for the > display to update before getLineIndexAtPoint() will return anything > other than -1. So my questions are: > > 1. Can you force the display to update immediately? > e.g. > this.text = "a new line of text"; > // this will return -1 (not what I want) > trace(this.textField.getLineIndexAtPoint(2)); > > forceUpdate(); > > // this will return 0 (good) > trace(this.textField.getLineIndexAtPoint(2)); > > 2. If you cannot force an update, is there an event to > listen for so that I know when the getLineIndexAtPoint() > method will return useful information? > > Here is my example code that does not give me what I want: > > public class MyTextArea extends TextArea { > public function MyTextArea() { > super(); > // wait for creationComplete otherwise this.textField = null > addEventListener(FlexEvent.CREATION_COMPLETE, onCreationComplete); > } > > private function onCreationComplete(evt:FlexEvent):void { > this.text = 'a long line of text \n with a line break ...'; > > // these both return -1 > // but I want them to return "0" and "1", repectively > // because char 1 is on line 1 and char 25 is on line 2 > trace(this.textField.getLineIndexOfChar(1)); > trace(this.textField.getLineIndexOfChar(25)); > } > > } > > (by the way, in my application, I unfortunately don't have the option > of setting this.text in the constructor). > > Thanks in advance for your help, > James > > >