Note that there are some explanatory texts on larger screens.

plurals
  1. POAIR App that Loads and Runs Existing AIR swf
    primarykey
    data
    text
    <p>I have an existing AIR app whose main content is App.swf. I would like to have another AIR app that hosts and runs App.swf. When I say run it, I mean displays it's WindowedApplication.</p> <p>Here's the code for the 2 AIR projects (imports are omitted for brevity):</p> <pre><code>// App AIR Project -&gt; App.mxml -&gt; App.swf (it's just a window) &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"&gt; &lt;mx:Script&gt; &lt;![CDATA[ public function doSomething():void { trace("doSomething called"); } ]]&gt; &lt;/mx:Script&gt; &lt;/mx:WindowedApplication&gt; // AirAppHostApplication AIR Project -&gt; AirAppHostApplication.mxml -&gt; AirAppHostApplication.swf &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;custom:AirAppHostApplication xmlns:custom="components.*" /&gt; // components/AirAppHostApplication.as 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(); } } </code></pre> <p>I get the following error while App.swf is being loaded:</p> <pre><code>TypeError: Error #1009: Cannot access a property or method of a null object reference. at mx.managers::SystemManager/initHandler()[C:\autobuild\galaga\frameworks\projects\framework\src\mx\managers\SystemManager.as:3001] </code></pre> <p>I believe the issue has to do with AirAppHostApplication's SystemManager conflicting with App's SystemManager because they are both living in the same app domain. Can an AIR app be written where a WindowedApplication class isn't statically defined, but loaded at runtime by loading a swf and instantiating the WindowedApplication subclass that's contained in the swf.</p> <p>The reason I want to do this is for an automation scenario where I have to assume I don't have the source code for the app I'm automating, but I do have access to the names of the public classes and their public methods exposed for automation. I have complete control over the environment and don't have to deal with any constraints around that, so I can put 2 AIR apps in the same directory, etc.</p> <p>Is this possible?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload