Skip to main content
Known Participant
July 2, 2010
Answered

TextLayoutFormat now TextLayoutFormatValueHolder?

  • July 2, 2010
  • 1 reply
  • 2130 views

I've recently upgraded to the latest version of TLF and am trying to publish one of my older projects but I am now getting an error that wasn't there before.

The error is this ...

TypeError: Error #1034: Type Coercion failed: cannot convert flashx.textLayout.formats::TextLayoutFormat@1bfe4041 to flashx.textLayout.formats.TextLayoutFormatValueHolder.

at flashx.textLayout.elements::LinkElement/computeLinkFormat()

at flashx.textLayout.elements::LinkElement/get http://ns.adobe.com/textLayout/internal/2008::effectiveLinkElementTextLayoutFormat()

at flashx.textLayout.elements::LinkElement/get http://ns.adobe.com/textLayout/internal/2008::formatForCascade()

at flashx.textLayout.elements::FlowElement/http://ns.adobe.com/textLayout/internal/2008::doComputeTextLayoutFormat()

at flashx.textLayout.elements::FlowElement/get computedFormat()

... etc

Is there something different about creating the TextLayoutFormat objects?

I'm creating a config file to set the formats like so ...

config = Configuration(TextFlow.defaultConfiguration).clone();

var linkNormalFormat:TextLayoutFormat = new TextLayoutFormat();

linkNormalFormat.color = 0x000000;

var linkHoverFormat:TextLayoutFormat = new TextLayoutFormat();

linkHoverFormat.color = 0xdc428f;

var defaultFormat:TextLayoutFormat = new TextLayoutFormat();

defaultFormat.color = 0x333333;

defaultFormat.textAlign = TextAlign.JUSTIFY;

defaultFormat.textAlignLast = TextAlign.JUSTIFY;

defaultFormat.fontSize = 10;

defaultFormat.lineHeight = 10;

defaultFormat.fontLookup = FontLookup.EMBEDDED_CFF;

defaultFormat.typographicCase = TypographicCase.UPPERCASE;

defaultFormat.renderingMode = RenderingMode.CFF;

defaultFormat.fontFamily = FontsManager.IMPACT;

config.textFlowInitialFormat = defaultFormat;

config.defaultLinkNormalFormat = linkNormalFormat;

config.defaultLinkHoverFormat = linkHoverFormat;

//config.defaultLinkActiveFormat = linkActiveFormat;

config.overflowPolicy = OverflowPolicy.FIT_DESCENDERS;

textFlow = new TextFlow(config);

Any help on this would be appreciated as this was supposed to be a five minute change for my client.

This topic has been closed for replies.
Correct answer rdermer

There's a few things going on here.

First that's a bug in LinkElement in TLF 1.1  You'll have to use TextLayoutFormatValueHolder in that case.

Background:

The TextLayoutFormat class was the original class for formatting.  It is a large object that reserves a slot for every TLF format.  Later we created TextLayoutFormatValueHolder and kept it internal (it's tagged with [ExcludeClass] metadata) because it was more efficient for storing formats when only a few were set.

In TLF 2.0 the original TextLayoutFormat class is replaced with TextLayoutFormatValueHolder and TextLayoutFormatValueHolder goes away.  Generally there's no place in the code anymore where every format is set.  For the computedFormat where every format has a value TLF is now using object prototypes siimilar to Flex - that started in 1.1 and that's where the bug got introduced.

Richard

1 reply

rdermerCorrect answer
Adobe Employee
July 2, 2010

There's a few things going on here.

First that's a bug in LinkElement in TLF 1.1  You'll have to use TextLayoutFormatValueHolder in that case.

Background:

The TextLayoutFormat class was the original class for formatting.  It is a large object that reserves a slot for every TLF format.  Later we created TextLayoutFormatValueHolder and kept it internal (it's tagged with [ExcludeClass] metadata) because it was more efficient for storing formats when only a few were set.

In TLF 2.0 the original TextLayoutFormat class is replaced with TextLayoutFormatValueHolder and TextLayoutFormatValueHolder goes away.  Generally there's no place in the code anymore where every format is set.  For the computedFormat where every format has a value TLF is now using object prototypes siimilar to Flex - that started in 1.1 and that's where the bug got introduced.

Richard

PoobeardAuthor
Known Participant
July 2, 2010
In TLF 2.0 the original TextLayoutFormat class is replaced with TextLayoutFormatValueHolder and TextLayoutFormatValueHolder goes away. 

Ok, so in 1.1 you have this internal class you've introduced to store the formats and this is why it's triggering the error. But how can I now set the formats for my Config if the TextLayoutFormatValueHolder class is not available to me? Can you give me an example of how this would work in 1.1 or is it just not going to?

Appreciate the help with this BTW.

Adobe Employee
July 2, 2010

It's available. ExcludeClass means it doesn't show up in the code hints.  It's in the list of classes TLF makes available external to the swc.

import flashx.textLayout.formats.TextLayoutFormatValueHolder;

Use it like a TextLayoutFormat - it has the same API.

Rich