[英]Flex sub-apps: App sdk 3.5 inside App sdk 4.5
我有一個在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"
/>
誰能幫我? 提前致謝。
我一直在從事與此類似的工作。 嘗試使用GreenSock中的LoaderMax。 http://www.greensock.com/loadermax/
我在我的系統中使用了多版本子應用程序,並嘗試了SystemManager,這導致無處可尋,我回到了LoaderMax。 我遇到了太多的RSL加載錯誤,而無法使用SystemManager。
您可能還會遇到需要編組支持的需求。
父應用程序是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),這些flashvars告訴它在加載過程中要做什么。 子應用程序是一個獨立的應用程序,可以在沒有此應用程序的情況下運行,因此它已成為雙重用途的應用程序。 1)獨立,2)子應用(inChildMode)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.