Home > Uncategorized > Error #1034: Type Coercion failed: cannot convert mx.graphics::Stroke to mx.graphics.IStroke.

Error #1034: Type Coercion failed: cannot convert mx.graphics::Stroke to mx.graphics.IStroke.

March 5th, 2009

This turned out to be a pretty haunting bug, and I still don’t quite understand what I did to fix it, but I did.

You’ve probably already seen the Adobe Bug SDK-9480 

And of couse you’ve seen an error that looks like so…..

TypeError: Error #1034: Type Coercion failed: cannot convert mx.graphics::Stroke@dfd3e21 to mx.graphics.IStroke.
    at mx.charts::AxisRenderer/measure()
    at mx.core::UIComponent/measureSizes()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:5956]
    at mx.core::UIComponent/validateSize()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:5902]
    at
mx.managers::LayoutManager/validateSize()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:579]
    at mx.managers::LayoutManager/doPhasedInstantiation()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:668]
    at Function/http://adobe.com/AS3/2006/builtin::apply()
    at mx.core::UIComponent/callLaterDispatcher2()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8628]
    at mx.core::UIComponent/callLaterDispatcher()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8568]

 

The situation only appears to occur when I am running a Module across Application Domains.  For me it worked fine, as I was developing the module stand alone with a Main.mxml that I was using as my loader for the Module. When I ported the module to my global application….I was not so lucky and it broke things.

To fix the bug you will need to make a change in the code that is loading the module. In 1 of the following 2 ways. I used the 2nd because forcing all modules into the same “currentDomain” broke other modules that were using shared classes.

Here are the 2 ways I know of to fix it.

 

1) Set the Application Domain in your ModuleLoader as follows

var Mod:ModuleLoader = new ModuleLoader();
Mod.applicationDomain = ApplicationDomain.currentDomain;

2) In your Parent Application not in the module itself. (Every module needs and application)

import mx.graphics.IStroke;
private var uStroke:IStroke;

Greg Uncategorized

  1. June 7th, 2009 at 16:08 | #1

    Really appreciate your post.
    Your second option works for me.
    Thank you
    Claude Hussenet

  1. No trackbacks yet.