anpegar
anpegar

Reputation: 1

Flex sub-apps: App sdk 3.5 inside App sdk 4.5

I have an application compiled in Flex 4.5 and I load (with SWFLoader) other application compiled in Flex 3.5, it works fine but when I execute the sentence "SystemManager(myLoader.content)" the system shows the error:

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]

This is Flex 4.5 application code:

<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"  
                 />         

Can anyone help me? Thanks in advance.

Upvotes: 0

Views: 241

Answers (1)

notDefault
notDefault

Reputation: 21

I've been working on something similar to this. Try using LoaderMax from GreenSock. http://www.greensock.com/loadermax/

Im using a multiversioned sub application in mine and tried SystemManager as well, this lead to nowhere and I went back to LoaderMax. I was getting way too many RSL loading errors and whatnot using SystemManager.

you might also be running into the need for Marshalling support.

The parent App is SDK 4.5, this shares two SWC files (4.5) with another application (4.6) The parent app loads an SDK 4.1 application into itself.

This is working for the most part, I am still trouble shooting linked assets and relative paths. But all in all, the application loads.

In the parent application view screen to load the child app:

[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(); 
            }

and the MXML for the placeholder:

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

The child application is setup to handle some new flashvars (this.parameters) which tell it what to do in its loading procedures. the child app is a standalone and can function without this, so it has now become a dual purpose application. 1) standalone, 2) child app (inChildMode)

Upvotes: 1

Related Questions