I get 3 using \n, and 5 using \r\n with this test:
package {
import flash.display.*;
import flash.events.*;
import flash.filters.*;
import flash.geom.*;
import flash.net.*;
import flash.system.*;
import flash.text.*;
import flash.ui.*;
import flash.utils.*;
import flash.xml.*;
public class test2 extends MovieClip
{
public var thing1:Sprite;
public var thing2:Sprite;
public var thing3:Sprite;
public var thing4:Sprite;
public var thing5:Loader;
public var thing6:Loader;
public var max:TextField;
public function test2()
{
super();
root.loaderInfo.addEventListener(Event.INIT, initialize);
}
public function initialize(event:Event):void
{
thing1 = new Sprite();
trace(thing1.name);
addChild(thing1);
thing1.graphics.beginFill(0xFF0000);
thing1.graphics.drawRect(0, 0, 500, 500);
thing1.graphics.endFill();
max = new TextField()
thing1.addChild(max);
max.x = 10;
max.y = 200;
max.width = 500;
max.height = 100;
max.multiline = true;
max.text = "Mary had a little lamb\r\nMary had a little lamb\r\n";
trace(max.numLines);
addEventListener("mouseDown", mouseDownHandler)
}
private function mouseDownHandler(event:Event):void
{
trace(max.numLines);
}
}
}
________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Dmitri Girski
Sent: Tuesday, May 06, 2008 8:21 AM
To: [email protected]
Subject: [flexcoders] Re: TextField - how does it calculate the number
of lines?
Anyone?
--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "Dmitri Girski" <[EMAIL PROTECTED]> wrote:
>
> Question to Alex and the rest from Adobe gang:
>
> Why the TextField does not include in numLines the number of lines
> which ends up with CR or LF?
>
> I.e. if you have a text:
>
> Mary has a little lamb<CR> (1)
> Mary has a little lamb<CR> (2)
>
> And the width of TextField is big enough to accommodate the whole
> string (1) without breaking it.
>
> TextField thinks that it has 2 lines. But when it starts rendering
> text it places the <CR> symbol and we ending up with 4 lines of text.
>
> Is this a bug or feature?
>
> PS this is .text property, not the .htmlText (which has similar
> problem of missing the <br>s from the count)
>
>
> Thanks!
>