0

我有一个在 Flex 4.5 中编译的应用程序并加载(使用 SWFLoader)在 Flex 3.5 中编译的其他应用程序,它工作正常,但是当我执行语句“SystemManager(myLoader.content)”时,系统显示错误:

TypeError: Error #1034: Error de conversión forzada: no se puede convertir _AnalizaOrganigramaTest_mx_managers_SystemManager@8450eb9 en mx.managers.SystemManager.
at AnaTestModule/_mlCargada()[C:\eanaliza\branch\peticiones3_p9184\40 flex\flex\AnaTestModule\src\AnaTestModule.mxml:28]
at AnaTestModule/__myLoader_complete()[C:\eanaliza\branch\peticiones3_p9184\40 flex\flex\AnaTestModule\src\AnaTestModule.mxml:43]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\core\UIComponent.as:13128]
at mx.controls::SWFLoader/http://www.adobe.com/2006/flex/mx/internal::contentLoaderInfo_completeEventHandler()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\controls\SWFLoader.as:2292]

这是 Flex 4.5 应用程序代码:

<fx:Script>
    <![CDATA[
        import mx.managers.SystemManager;

        [Bindable]
        public var loadedSM:SystemManager;

        protected function _mlInit():void
        {
            myLoader.source = "/analiza_peticiones3_p9184/AnalizaOrganigramaTest-debug/AnalizaOrganigramaTest.swf";
            myLoader.load();
        }
        private function _mlCargada():void
        {
            loadedSM = SystemManager(myLoader.content);             
        }
    ]]>
</fx:Script>

<s:SWFLoader id="myLoader"  
             loadForCompatibility="true" 
             complete="_mlCargada();" 
             maintainAspectRatio="true" 
             scaleContent="false"  
                 />         

谁能帮我?提前致谢。

4

1 回答 1

1

我一直在做类似的事情。尝试使用 GreenSock 的 LoaderMax。 http://www.greensock.com/loadermax/

我在我的中使用了一个多版本的子应用程序并尝试了 SystemManager,这导致无处可去,我又回到了 LoaderMax。使用 SystemManager 时,我遇到了太多 RSL 加载错误和诸如此类的错误。

您可能还需要编组支持。

父应用程序是 SDK 4.5,它与另一个应用程序 (4.6) 共享两个 SWC 文件 (4.5) 父应用程序将一个 SDK 4.1 应用程序加载到自身中。

这在很大程度上是有效的,我仍然在解决链接资产和相对路径的问题。但总而言之,应用程序加载。

在父应用程序视图屏幕中加载子应用程序:

[Bindable] private var childAppLink= "http://myserver.com/AppRoot/@@version/controls/Application.swf";
[Bindable] private var altChildAppLink:String = "/AppRoot/@@version/controls/Application.swf";
[Bindable] private var loaderQueue:LoaderMax = new LoaderMax({name:"ChildApp4_0_Loader",onProgress:handleLoaderProgress,onComplete:handleLoaderComplete,onError:handleLoadingError});

protected function loadUsingLoaderMax():void
        {
            childAppLink= StringUtils.replace(childAppLink,'@@version',cm.s.childAppVersion);
            altChildAppLink= StringUtils.replace(altChildAppLink,'@@version',cm.s.childAppVersion);

            var swfvars:SWFLoaderVars = new SWFLoaderVars();
            var loaderRequest:URLRequest = new URLRequest();
            var loaderVars:URLVariables = new URLVariables();
            var loaderContexts:LoaderContext = new LoaderContext();

            LoaderMax.contentDisplayClass = FlexContentDisplay;

            loaderVars.DEBUG            = cm.s.debug;
            loaderVars.inChildMode      = "true"; //set this as a string!
            loaderVars.bpu              = String(u.userId + ';' + u.currentLocationId);
            loaderVars.sv               = cm.s.childAppVersion;
            loaderVars.KEYWORD          = 'XXXXX';

            loaderContexts.applicationDomain = new ApplicationDomain();

            if(Security.sandboxType == Security.REMOTE)
                loaderContexts.securityDomain = SecurityDomain.currentDomain;

            loaderRequest.url = childAppLink;
            loaderRequest.data = loaderVars;
            loaderRequest.method = URLRequestMethod.GET;

            swfvars.name("ChildApplication_4_0");
            swfvars.estimatedBytes(410000000);
            swfvars.container(ChildAppPH);
            swfvars.x(0);
            swfvars.autoPlay(true);
            swfvars.scaleMode("none");
            swfvars.alternateURL(altChildAppLink);
            swfvars.context(loaderContexts);

            loaderQueue.append(new com.greensock.loading.SWFLoader(loaderRequest,swfvars) );

            this.addEventListener("mx.managers.SystemManager.isBootstrapRoot", systemManagerHandler);
            this.addEventListener("mx.managers.SystemManager.isStageRoot", systemManagerHandler);
            ShoplandPlaceholder.systemManager.addEventListener(FlexEvent.CREATION_COMPLETE,handleLoaderComplete);

            loaderQueue.load();
            ChildAppPH.visible = false;
            ChildAppPH.alpha = 0;
        }

protected function systemManagerHandler(event:Event):void
            {
                event.preventDefault(); 
            }

以及占位符的 MXML:

<s:SWFLoader id="ChildAppPH" width="1010" height="610" verticalCenter="305" horizontalCenter="505" top="10" />

子应用程序设置为处理一些新的 flashvars (this.parameters),告诉它在加载过程中要做什么。子应用程序是独立的,可以在没有它的情况下运行,因此它现在已成为一个双重用途的应用程序。1)独立,2)子应用程序(inChildMode)

于 2012-08-08T14:34:44.937 回答