Skip to main content
Participant
June 13, 2010
Question

Containercontrollers and textflow, get individual text fragments

  • June 13, 2010
  • 1 reply
  • 725 views

Hi!

I am creating multiple RichText components (from code), which i then connect to textflow by adding multiple containercontrollers.

This all works great.

But now my question: Is it possible to get the html content from each specific containercontroller. I have tried a number of things for example,

editor = event.currentTarget as RichText;
var tf:TextFlow = editor.content as TextFlow;
trace(TextConverter.export(tf, TextConverter.TEXT_FIELD_HTML_FORMAT, ConversionType.STRING_TYPE).toString());

but this only produces a piece of html code without the actual text from the RichText field.

Anyone have an idea?

Thanx

Maurice

This topic has been closed for replies.

1 reply

Adobe Employee
June 14, 2010

Hmm.. you're trodding unchartered ground, since Flex doesn't support multiple containers. You're on the right track by using the TextConverter, but its not clear given your setup how to get a valid textFlow. I suspect that if you were successful in connecting multiple RichText components, you'd have a single flow, and therefore just one of them might have a valid TextFlow that you could access. You may have to either keep a reference from before you set up the linked containers, or try accessing the TextFlow from the ContainerController and not from the RichText component.

- robin

Participant
June 15, 2010

Hi Robin,

thanx for your response.

I am working with Flash Builder 4, so i am not quite sure what you mean by Flex not being able to use multiple containers?

I am plotting uncharted ground, i am well aware of that, but for our application i need to make this work.

So... what is happening is i am import a string into a textflow. I create f.e. two containercontrollers which have a RichText component as the element for the controller.

The textflow is then visible in these two containers, this works fine.

But what i need to know is which part of the textflow is in which controller. That is not working for me, and i have tried many things. Strange thing is when i get the textflow from the element (on the textline level!) i just get the complete textflow again?

I know i am asking a lot, but any small pointers are appreciated.

Thanx

Maurice

Adobe Employee
June 17, 2010

If you look in the controller, it has two properties -- absoluteStart and textLength. "absoluteStart" is the location of the text at the start of the controller, as an offset from the start of the TextFlow. "textLength" is the number of characters in the controller. These are updated when the text is recomposed. So the first controller's absoluteStart will be zero, and the subsequent controller's absoluteStart will be the sum of the previous controller's textLength(s).

Hope this helps,

- robin