我想加载一个SWF到Flex 4应用程序中以使用它的类。Adobe Flash Builder(flex4):addChild()在此类中不可用。
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); }
我收到的错误:
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:\dev\gumbo_beta2\frameworks\projects\spark\src\spark\components\supportClasses\SkinnableComponent.as:966]
at main/private:init/loaded()[C:\Documents and Settings\ufk\Adobe Flash Builder Beta 2\xpogames-toolkit-test\src\main.mxml:22]
如果我改变addChild()
到addElement()
,我收到以下编译错误:
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
任何想法如何解决这个问题?
扩展到MovieClip,然后添加到UIComponent的作品。 – ufk 2011-08-16 08:11:06