Skip to main content
A_Shiyaz
Known Participant
January 29, 2010
Question

Loading multiple swf with dynamic TLF gives Error #1034: Type Coercion failed

  • January 29, 2010
  • 1 reply
  • 1572 views

Hi, i have made a swf which can read text from external xml and create dynamic TLF on stage. This swf works fine as stand-alone or if loaded within another main swf. However, when more than one swf with TLF content is loaded, then i get this error:

TypeError: Error #1034: Type Coercion failed: cannot convert flashx.textLayout.container::DisplayObjectContainerController@eaabc69 to flashx.textLayout.container.IInternalContainerController.
    at Vector$object/http://adobe.com/AS3/2006/builtin::push()
    at flashx.textLayout.compose::StandardFlowComposer/addController()
    at com.tis::TextImage/parseConfig()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at com.tis::ResourceObject/completeHandler()
    at MethodInfo-22()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()

Individually they work perfectly. They work fine if i load either of the files. The moment i try to load both files, i get this error. This is the code for generating the TLF.

var markup:String = assets.children().children()[0];
var flow:TextFlow = TextFilter.importToFlow(markup, TextFilter.TEXT_LAYOUT_FORMAT);
flow.flowComposer = new StandardFlowComposer();
var firstContainer:Sprite = new Sprite();
var firstController = new DisplayObjectContainerController(firstContainer, assets.children().@width,assets.children().@height);
firstContainer.x = assets.children().@x;
firstContainer.y = assets.children().@y;
flow.flowComposer.addController(firstController);
contentTF_mc.addChild(firstContainer);
flow.addEventListener(CompositionCompletionEvent.COMPOSITION_COMPLETE, function(e):void{composeListener(e, firstController)});
flow.flowComposer.updateAllContainers();

I noticed that the error happens at this line:

flow.flowComposer.addController(firstController);

Where am i going wrong?

Regards,
Shiyaz

This topic has been closed for replies.

1 reply

Adobe Employee
January 29, 2010

Hard to say - the version of TLF you are using is over a year old and huge amounts of work have been done in that time.  You're going to need to update to a more recent version before we can be of much help.  It's going to be a large upgrade as well.

You can obtain the most recent textLayout.swc in the Flex Gumbo SDK downloads.  You'll need to discard the Flash 4 prototype plugin and the three textLayout swcs that came with it.

The latest swc and docs can be found here:

http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4

Sorry I can't be more help - maybe someone else can but this is how I recomend you proceed.

Richard

A_Shiyaz
A_ShiyazAuthor
Known Participant
January 30, 2010

Dear Richard, am using the latest Flex sdk 4.0.0.10485 and the app is developed in Flash CS4. You are right in pointing out that the swc that comes with the sample (

http://labs.adobe.com/downloads/textlayout.html) is outdated (textlayout_flashcomponent_p1_111808; the library timestamp says a date: 11.14.2008). However, in addition to having this component in the library, I do use the additional swc that comes with the examples (TLF_Examples swc date stamp: 9.22.2009) and have linked this to the External Library Path of my FLA. Without this, some of the methods from the example do not work.

You had advised "You can obtain the most recent textLayout.swc in the Flex Gumbo SDK downloads.  You'll need to discard the Flash 4 prototype plugin and the three textLayout swcs that came with it.". I will try and use the latest swc and try to create a dynamic TLF.

If I may add, can you please let me know if the swc found at http://opensource.adobe.com/svn/opensource/flex/sdk/trunk/frameworks/libs/ (Trunk 13879 date stamp: 1.27.2010) should be used rather than the one found at http://labs.adobe.com/downloads/textlayout.html?

Thanks and regards,
Shiyaz
A_Shiyaz
A_ShiyazAuthor
Known Participant
February 1, 2010

I have found the solution. I just had to import the TextLayout swc in the library of the base file too. Just for the record, these are the various libraries/versions I had to use for the implementation:

  • Flash CS4 with Flex SDK 4.0.0.10485.
  • TLF_Installed by MXP_11.14.2008 - TextLayout component in the libraries of the base(loader) file and all the FLA files which needs TLF.

Regards,

Shiyaz