You can most certainly load SWFs into other SWFs, but you cannot re-parent (addChild) the content into the other SWFs containers if the two SWFs are in different application domains. That's because the children of Flex containers must be IUIComponents and objects in another applicationdomain do not share the same definition of IUIComponent.
Alex Harui Flex SDK Developer Adobe Systems Inc.<http://www.adobe.com/> Blog: http://blogs.adobe.com/aharui From: [email protected] [mailto:[email protected]] On Behalf Of hamza bakkali Sent: Thursday, August 13, 2009 3:59 AM To: [email protected] Subject: [flexcomponents] : Loading one SWF into another one Hi all, I am getting to the conclusion that the following is not supported at all. (Using flex 3.2 SDK): Loading one SWF into another one using 2 different loaderContext. I tried using the Loader and the SWFLoader (and to some extend the ModuleLoader) 1- Build a simple Flex App with a combo box or Alert Message (on click of a button for instance). (=="TestCombo.swf") 2. Load that SWF (from Step 1) using the Loader in a new application Domain (as such: var request:URLRequest = new URLRequest("TestCombo.swf"); _loader = new Loader(); _loader.contentLoaderInfo.addEventListener(Event.COMPLETE,handleModuleLoaded); _loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,handleError); _loader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR,han\ dleError); _loader.contentLoaderInfo.addEventListener(Event.UNLOAD, unloadHandler1); var context:LoaderContext = new LoaderContext(); context.applicationDomain = new ApplicationDomain(); // that's KEY! _loader.load(request,context); In the handleModuleLoaded function, I am simply adding the content of the comboSWF into a vbox vbx.rawChildren.addChild(_loader.content); 3. Attempt to see the content of the combo or click on the button to see the Alert from the loaded SWF, and you get an exception. (see below) TypeError: Error #1009: Cannot access a property or method of a null object reference. at mx.managers::SystemManager/addPopupRequestHandler()[C:\autobuild\3.2.0\framework\ s\projects\framework\src\mx\managers\SystemManager.as:3604] at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.managers::PopUpManagerImpl/addPopUp()[C:\autobuild\3.2.0\frameworks\projects\\ framework\src\mx\managers\PopUpManagerImpl.as:294] at mx.managers::PopUpManager$/addPopUp()[C:\autobuild\3.2.0\frameworks\projects\fra\ mework\src\mx\managers\PopUpManager.as:169] at mx.controls::Alert$/show()[C:\autobuild\3.2.0\frameworks\projects\framework\src\\ mx\controls\Alert.as:519] at TestCombo/___TestCombo_Button1_click()[M:\projects\flex-projects\TestCombo\src\T\ estCombo.mxml:16] The same code works perfectly fine if you attempt to load the SWF into the same applicationDomain, but that's totally not acceptable for us here. Using the SWFLoader as opposed to the Loader does not even get you this far. The TestCombo.swf is not even loaded. I get the following exception when trying to load the module: (basically complaining about the system Manager being null) TypeError: Error #1009: Cannot access a property or method of a null object reference. at mx.controls::SWFLoader/initSystemManagerCompleteEventHandler()[C:\autobuild\3.2.\ 0\frameworks\projects\framework\src\mx\controls\SWFLoader.as:2174] at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.managers::SystemManager/initHandler()[C:\autobuild\3.2.0\frameworks\projects\\ framework\src\mx\managers\SystemManager.as:2862] Anything would help. I just need to know whether that's possible or not using flex sdk 3.2. Cheers.
