I have an existing AIR application whose main content is App.swf. I would like to have another AIR application that hosts and runs App.swf. When I say run it, I mean display it WindowedApplication.
Here is the code for 2 AIR projects (import reduced for brevity):
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
public function doSomething():void {
trace("doSomething called");
}
]]>
</mx:Script>
</mx:WindowedApplication>
<?xml version="1.0" encoding="utf-8"?>
<custom:AirAppHostApplication xmlns:custom="components.*" />
public class AirAppHostApplication extends WindowedApplication
{
private var ldr:Loader;
public function AirAppHostApplication()
{
addEventListener (FlexEvent.CREATION_COMPLETE, handleComplete);
}
private function handleComplete( event : FlexEvent ) : void
{
loadSwf("App.swf");
}
private function loadSwf(swf:String):void {
ldr = new Loader();
var req:URLRequest = new URLRequest(swf);
var ldrContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
ldr.load(req, ldrContext);
}
private function completeHandler(event:Event):void {
var appSystemManagerCls:* = ApplicationDomain.currentDomain.getDefinition("_app_mx_managers_SystemManager") as Class;
var appSystemManagerInstance:* = new appSystemManagerCls(Application.application);
var appInstance:WindowedApplication = appSystemManagerInstance.create();
appInstance.activate();
appInstance.doSomething();
}
}
When loading App.swf, the following error appears:
TypeError: Error
at mx.managers::SystemManager/initHandler()[C:\autobuild\galaga\frameworks\projects\framework\src\mx\managers\SystemManager.as:3001]
I believe the problem is with the AirAppHostApplication SystemManager, which conflicts with the App SystemManager, because they both live in the same application domain. Can an AIR application be written where the WindowedApplication class is not statically defined but loaded at runtime by loading swf and subclassing WindowedApplication contained in swf.
, , - , , , , , . , - , 2 AIR ..
?