Skip to main content
Known Participant
July 27, 2011
Question

Utility class or method that help determines TextConverter format to use

  • July 27, 2011
  • 1 reply
  • 410 views

We currently create a TextFlow using the TextConverter.importToFlow method and either choose the TEXT_LAYOUT_FORMAT or TEXT_FIELD_HTML_FORMAT types of format based on the content of the String.  The String can contain new TLF markup or the markup supported by the TextField.htmlText.  We don't know what the content will be until runtime.  I was wondering if there was a utility method or class that I could use that would create the TextFlow for me OR somehow parse the String to let me know which type of format to pass into the TextConverter.importToFlow method.

I'm currently doing the following, but would like something better if possible.

if ( content.indexOf("TextFlow") != -1 )
{
textFlow = TextConverter.importToFlow(content,TextConverter.TEXT_LAYOUT_FORMAT);
}
else
{
textFlow = TextConverter.importToFlow(content,TextConverter.TEXT_FIELD_HTML_FORMAT);
}

Thanks!

I see the TextFlowUtil class but it fails when my old HTML includes '<b>' and '<i>' tags which I guess falls under invalid markup.  Just wondering if I'm missing something or doing the right thing.

This topic has been closed for replies.

1 reply

Adobe Employee
July 29, 2011

Sadly, TLF won't have the utility class or method to determine which format that should be used. TLF is designed as a framework, and TLF provide you all type of importer. It's up to you which one to choose.

TextFlowUtil is a Flex SDK class, which is also open source. And TextFlowUtil.importFromString or importFromXML actully call  TextConverter.importToFlow. If you think TextFlowUtil is good, you can refer to its code to make your own utility class.