Skip to main content
Known Participant
May 19, 2011
Question

Passing in Configuration object causes importToFlow to return null

  • May 19, 2011
  • 1 reply
  • 579 views

Hi!  I'm trying to style hyperlinks (href's) in a TextFlow using a Configuration class.  I basically copied the example from here: http://help.adobe.com/en_US/flex/using/WS02f7d8d4857b1677-165a04e1126951a2d98-7fef.html.  But the returned TextFlow is coming back null.

Here is a snippet of my code:

var textFlow:TextFlow = null;

/*** Configuration ***/
var cfg:Configuration = new Configuration();

var normalFmt:TextLayoutFormat = new TextLayoutFormat(cfg.defaultLinkNormalFormat);
normalFmt.color = 0xFF0000; // red
normalFmt.textDecoration = TextDecoration.NONE;

var hoverFmt:TextLayoutFormat = new TextLayoutFormat(cfg.defaultLinkHoverFormat);
hoverFmt.color = 0xFF00FF; // purple
hoverFmt.textDecoration = TextDecoration.UNDERLINE;

cfg.defaultLinkNormalFormat = normalFmt;
cfg.defaultLinkHoverFormat = hoverFmt;
/*********************/

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

If I remove the 'cfg' from the "importToFlow" method call, I get the default link colors (blue).  Also, even if I go through the "TextConverter.TEXT_FIELD_HTML_FORMAT" with a 'cfg' object passed in, I get null returned.

Is using the Configuration object the best way to style the links?  What is the preferred method?

Thanks!

This topic has been closed for replies.

1 reply

dacaglSASAuthor
Known Participant
May 19, 2011

I believe I have it figured out.

Instead of using "TextLayoutFormat", I had to use "TextLayoutFormatValueHolder" instead.

I saw the comments at the bottom of http://help.adobe.com/en_US/flex/using/WS02f7d8d4857b1677-165a04e1126951a2d98-7fef.html mentioning "TextLayoutFormatValueHolder" but I wasn't getting any code hints, so I thought it didn't exist anymore or something.  After Googling, I came across an old thread that does a pretty good job of explaining things... http://forums.adobe.com/thread/672521.

It's still rather confusing though but it appears to be working.