Skip to main content
Oct 14, 2009 4:31 PM UTC
Question

Create TextLine by character count?

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 is closed to new replies. Start a new post to keep the conversation going.

2 replies

a_circulo
Participating Frequently
Oct 15, 2009 2:58 AM UTC

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..

Translate
Adobe Employee
Oct 14, 2009 5:13 PM UTC

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

Translate