Yes I thought so as well, but this doesn't seems to work. Below you
can find my code example.

So what I see on the screen are the first two lines of text with the
following content:

This is the fist line of text. 
And this is the second line.

But the trace log (even after super.updateDisplayList) shows that
there are still five lines with the following content. 

textField.numLines:5
textField.getLineText(0):This is the first 
textField.getLineText(1):line of text. And 
textField.getLineText(2):this is the 
textField.getLineText(3):second line. 
textField.getLineText(4):Third line is this.

Hope this helps.

Markus




This my example application:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
xmlns:components="components.*" layout="absolute">
        <components:MyText text="This is the first line of text. And this is
the second line. Third line is this." width="157" height="40"/> 
</mx:Application>

Here is my example class (derived from Text):

package components
{
  import mx.controls.Text;

  public class MyText extends Text
  {
    public function MyText()
    {
      //TODO: implement function
      super();
    }
                
    override protected function
updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
    {           
      super.updateDisplayList(unscaledWidth,unscaledHeight);

      trace('textField.numLines:' + textField.numLines);
                
      for (var i:uint = 0; i < textField.numLines; i++)
      {
        trace ('textField.getLineText('+ i.toString() + '):' +
textField.getLineText(i));
      }                 
    }   
  }
}








--- In flexcoders@yahoogroups.com, "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> You should be all set after super.updateDisplayList().
> 
>  
> 
> ________________________________
> 
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
> Behalf Of kramus0
> Sent: Wednesday, October 24, 2007 9:23 AM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Re: Number of lines in <mx:text/>
> 
>  
> 
> Thanks for your help. 
> 
> But when is the text in the textField actually layouted? I have tried
> to get the right lines (that I acutally see in the end) after
> commitProperties and updateDisplayList - but there is always the wrong
> text in the textField properties. For instance I get 5 lines even if
> there are only 3 lines displayed in the end. 
> 
> I have tried to set the width and height of the textField but this
> also didn't work.
> 
> Any suggestions? Thanks.
> 
> Markus
> 
> --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
> , "Alex Harui" <aharui@> wrote:
> >
> > Subclass, get to the internal TextField and get numLines. There are
> > other apis on TextField to get line content
> > 
> > 
> > 
> > ________________________________
> > 
> > From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
> [mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
> ] On
> > Behalf Of kramus0
> > Sent: Tuesday, October 23, 2007 9:34 AM
> > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> 
> > Subject: [flexcoders] Number of lines in <mx:text/>
> > 
> > 
> > 
> > This might be fairly simple but how can I find out how many lines a
> > text contains? If I for instance assign some long text to a text field
> > it is separated in different lines if the control height is big
> enough.
> > 
> > So how can I find out how many lines are there and what their content
> > is?
> > 
> > Thanks a lot.
> > 
> > Markus
> >
>


Reply via email to