Flex Error #1034: Type Coercion Failed: Cannot Convert *** to mx.core.IFlexDisplayObject

When you keep getting:

Flex Error #1034: Type Coercion Failed: Cannot Convert *** to mx.core.IFlexDisplayObject

… after using getDefinition() method, in my case:

// url = "../some.swf"
var request:URLRequest = new URLRequest(url);
var context:LoaderContext = new LoaderContext();
context.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, assetsComplete);
loader.load(request, context);
...
// assetsComplete()
var applicationDomain:ApplicationDomain = assetsLoader.contentLoaderInfo.applicationDomain;
var assetsClass:Class = applicationDomain.getDefinition("Assets") as Class;
...

The problem is, in fact, the security not coercion! Try move your .swf (the one that is beeing loaded) into the same directory where master .swf file is located.

Leave a comment

Please be polite and on topic. Your e-mail will never be published.