Skip to main content
June 17, 2009
Question

How to get the textLines in a RichText control

  • June 17, 2009
  • 1 reply
  • 992 views

I am trying to get hold of the individual lines that make up the RichText control once I set the text on it.  I am able to see the RichText.textLines property in the debug window (by creating a watch expression) - but when I try to access it in code, the compiler throws an error. 

I even created a subclass of RichText and tried writing a getter for it, but still the same compiler error:

"Attempted access of inaccessible property textLines..."

Is there any other way I can do this?

Thanks,

Om

This topic has been closed for replies.

1 reply

Participating Frequently
June 18, 2009

I don't remember whether this has changed since beta, but in current builds 'textLines' is an undocumented property in the mx_internal namespace. You can access it (at your peril, because it isn't guaranteed to be there in the future) by doing

import mx.core.mx_internal;

use namespace mx_internal;

I'd like to understand your use case... what will you do with the TextLines?

Gordon Smith

Adobe Flex SDK Team

June 18, 2009

Few of my use cases:

1.  Since I am matching Flash to follow some other text rendering algorithm (SVG/Batik in this case), I would like more control over where to break, etc.  I have a few edge cases where I need to know what goes in each line.

So I plan to inspect each TextLine and based on the TextLine.rawTextLength find out what text goes in each line. I would alter the text of the RichText control based on my set of rules.

2.  Sometimes the RichText control displays partial last lines even when truncation is turned on.  I want to manually add the textHeights of each line and ensure that none of them go out of the bounds.

I did try using a StringTextLineFactory to just create my own text control.  But I ran into some other issues(setting the firstBaselineOffset).  Hence i am using RichText control and using these techniques to gain fine control over the text's appearance.

Thanks,

Om

Participating Frequently
June 18, 2009

> Sometimes the RichText control displays partial last lines even when truncation is turned on.

This sounds like a bug. Could you please file it?

Gordon Smith

Adobe Flex SDK Team