我想加載一個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