Loading multiple swf with dynamic TLF gives Error #1034: Type Coercion failed
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
