Flex:类型强制失败:无法将flash.display :: Loader @ 47262f1转换为mx.core.IUIComponent

时间:2012-03-05 06:51:28

标签: flex load flash

Hai我有一个尝试加载swf的应用程序,但我无法加载swf我收到了以下错误。

TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Loader@47262f1 to mx.core.IUIComponent.
at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::addingChild()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Container.as:3900]
at mx.core::Container/addChildAt()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Container.as:2606]
at mx.core::Container/addChild()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Container.as:2534]
at slideSelection/init()[C:\Users\Administrator\Adobe Flash Builder 4\slideSelection\src\slideSelection.mxml:26]
at slideSelection/___slideSelection_Application1_creationComplete()[C:\Users\Administrator\Adobe Flash Builder 4\slideSelection\src\slideSelection.mxml:3]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:12266]
at mx.core::UIComponent/set initialized()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:1577]
at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:759]
at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1072]

加载swf的代码

var request:URLRequest = new URLRequest("http://xx/loading.swf");
                var loader:Loader = new Loader()
                loader.load(request);
                addChild(loader);

1 个答案:

答案 0 :(得分:2)

            var request:URLRequest = new URLRequest("http://name.swf");
            var loader:Loader = new Loader()
            loader.load(request);
            uic.addChild(loader);

           <mx:UIComponent id="uic" width="100%" height="100%"/>