Skip to main content
October 14, 2009
Question

Create TextLine by character count?

  • October 14, 2009
  • 2 replies
  • 648 views

TextBlock.createTextLine() renders as much text as in can within a given width.  Is there any way to create a TextLine with a specific number of characters or create a TextLine with a maximum number of characters?

This topic has been closed for replies.

2 replies

a_circulo
Participating Frequently
October 15, 2009

Hi Daniel

probably what you need is simpler than you think, just use String.substr

When you set the TextElement if would look like this:  new TextElement(yourString.substr(0, theMaxCharLength));

It would be practical to have a maxChar setting on the TextElement, but this solution is dead simple..

Adobe Employee
October 14, 2009

There's no direct way, but a TextLine will go until it gets to a soft line break or an end of paragraph, or when it has filled up its target space. So to get it to stop at a certain place, eiither put in a <br/> or an end of paragraph. To get it to take more characters, you can set lineBreak="explicit" on the TextFlow. Then the TextLines will fill up until they get to the end of the paragraph.

So if you knew exactly where you wanted the breaks to go, you could put a paragraph break at each location, and set the TextFlow to lineBreak="explicit".

Hope this helps,

- robin