I want to load an swf into a flex 4 application in order to use its classes.
var ldr:Loader=new Loader();
ldr.load(new URLRequest("file://path/to/fileswf"));
ldr.contentLoaderInfo.addEventListener(Event.INIT, loaded);
function loaded(evt:Event):void { addChild(ldr); }
I receive the error:
Error: addChild() is not available in this class. Instead, use addElement() or modify the skin, if you have one.
at spark.components.supportClasses::SkinnableComponent/addChild()[E:devgumbo_beta2frameworksprojectssparksrcsparkcomponentssupportClassesSkinnableComponent.as:966]
at main/private:init/loaded()[C:Documents and SettingsufkAdobe Flash Builder Beta 2xpogames-toolkit-testsrcmain.mxml:22]
If I change addChild()
to addElement()
, I receive the following compilation error:
1067: Implicit coercion of a value of type flash.display:Loader to an unrelated type mx.core:IVisualElement. main.mxml path/dir line 22 Flex Problem
Any ideas how to resolve this issue?