1 Reply Latest reply on Mar 10, 2010 9:18 AM by slingsla0

    Textfield getLineLength function returning 0 chars

    slingsla0

      I am creating a TextBox class that extends textArea in actionscript in adobe flex.  Let's say I create an instance of this TextBox class called textBox1 and set the text equal to a textArea called textArea1 that contains a sentence:

       

      textArea1.text = "Jack and Jill went up the hill";

       

      textBox1 = new TextBox;

       

      textBox1.text = textArea1.text;

       

      Now I want to use the textfield methods to get line information etc such as finding the length of particular lines in textBox1.  When I call the internal textfield function getLineLength as such:

       

      (textBox1.getTextField() as TextField).getLineLength(lineNum)

       

      it gives me 0 chars.  but then when I create a separate button that calls the getLineLength method when clicked, it will give me the correct number of chars when clicked.  I'm assuming that this is because the mouse event click on the button causes the textBox1 to re-render on the display so that it becomes possible to get the lengths of individual lines in the textfield?  I want to figure out how to update the display to get the line lengths (and use other similar textfield methods) internally through actionscript without any user driven events.

       

      I think this might be a pretty basic question regarding the textfield class and the flash rendering system in general but this is my first time really diving into either.  Thanks in advance!