Skip to main content
Inspiring
January 9, 2009
Answered

Type Coercion failed - error

  • January 9, 2009
  • 7 replies
  • 3199 views
Hi,

I use a ModuleLoader to load/unload mxml modules. One of these modules contains TextFlows. When this module gets loaded everything is fine and the textFlow displays fine.

However, when I unload() the module and load() again I get the following error:

Error #1034: Type Coercion failed: cannot convert flashx.textLayout.container::DisplayObjectContainerController@8f6e1a1 to flashx.textLayout.container.IInternalContainerController.

Here is the code i use:
This topic has been closed for replies.
Correct answer rdermer
It's a player bug with the use of a Vectof of interfaces. I converted the TLF code to use Array. Builds 346 and later have the fix.

7 replies

May 6, 2009

Hi there,

I am getting the same error using the Component for Flash CS4 and it's a quite old version. There's unfortunately no newer version for the Component. Could I override the method in the StandardFlowComposer class or change the source code somehow? Any ideas?

Thanks,

Korkut

Adobe Employee
January 22, 2009
namespace issues - we're wrestling with this one a bit.

By requiring the namespace this means future versions can detect an older namespace and adjust. That's the general plan.

When no namespace is specified we could assume its the latest version or generate an error. The code has flipped on this issue - I lean towards the current (generate an error) behavior.

Opinions?

Thanks,
Richard
Nikos_Author
Inspiring
January 23, 2009
I guess it depends on backwards compatibility of namespaces..

Defaulting to the latest version should be ok as long as it works.

* Is it possible to set it dynamically? How, if the parser requires it?

nikos
Adobe Employee
January 21, 2009
The import is probably failing. Make sure the namespace is speified. You can see the errors better if you do the import like this:
var parser:ITextImporter = TextFilter.getImporter(TextFilter.TEXT_LAYOUT_FORMAT);
var textFlow:TextFlow = parser.importToFlow(content);

Take a look at parser.errors
Nikos_Author
Inspiring
January 22, 2009
Hi Richard,

Thanks for your help once again.

The parser was throwing an 'Unexpected namespace' error cause I hadn't included the namespace: xmlns=' http://ns.adobe.com/textLayout/2008'

That seems like a requirement in the new builds as it was fine with the last one. Is the namespace likely to be changed in the future and how this would affect the parser? For example, would I have to replace the old namespace with the new one in all my text objects?!

thanks
n.
Adobe Employee
January 21, 2009
You can find them here.
http://opensource.adobe.com/svn/opensource/flex/sdk/trunk/frameworks/libs/
These are the latest versions integrated into the public flex trunk.

Regards,
Richard
Nikos_Author
Inspiring
January 21, 2009
Thanks Richard, Muhammad,

I have tried the latest TLF build, both from gumbo and the standalone version, and I now get a null object reference error:

Error #1009: Cannot access a property or method of a null object reference.

, in line:

_text.flowComposer.addController(_controller);

It seems that _text doesn't get initialised with TextFilter.importToFlow anymore

Any ideas?

n.
rdermerCorrect answer
Adobe Employee
January 20, 2009
It's a player bug with the use of a Vectof of interfaces. I converted the TLF code to use Array. Builds 346 and later have the fix.
Nikos_Author
Inspiring
January 21, 2009
Thanks rdermer..

Where do I get the latest build from? The only one I can see is http://labs.adobe.com/downloads/textlayout.html and I am sure is the one I use now.

thanks
n
Participating Frequently
January 21, 2009
Latest gumbo builds with TLF: http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4.
I don't if TLF builds are available separately from other link.
Adobe Employee
January 13, 2009
I was able to duplicate this. It's a bit puzzling as the DisplayObjectContainerController implements that interface. I filed a bug - it's going to take some investigation.

Thanks,
RIchard
Nikos_Author
Inspiring
January 13, 2009
Thanks RIchard,

Please keep me posted..

cheers
Nikos
Nikos_Author
Inspiring
January 20, 2009
Any updates?!

Thanks
Nikos
Adobe Employee
January 9, 2009
What happens when you remove the cast to IInternalContainerController in addController? That's not the right type. As coded no cast is needed. The line should read
addController(_controller).

I haven't experimented with load and unload.
Nikos_Author
Inspiring
January 10, 2009
It gives me the same error (I casted it, in case it fixes it)..

I have also tried calling _text.flowComposer.removeAllControllers(); and _text = null; on removedFromStage, but it makes no difference.

nikos
Nikos_Author
Inspiring
January 12, 2009
Tried:

var _controller:IContainerController = new DisplayObjectContainerController(_container, canvas.width, canvas.height);
_text.flowComposer.addController(_controller);

,as described in the textlayout_framework_overview.pdf, and I get the same error.

Any help would be much appreciated..

Thank you
Nikos