In AIR, I’m able to use a single swf for a worker and main thread by using something similar to the code below, which I’ve embedded in Flex in two ways.
Using a Flex Application object, the following code launches a worker, and I get the error "Error: Error #3731: This feature is not available within this context.” which I’d assume is because the Application is attempting to be loaded from the worker, after being loaded from the main thread. I tried a mobile app also, specifically TabbedViewNavigatorApplication. This actually gets farther, the worker is created, but as expected init() doesn’t fire, because applicationComplete has already fired, so “is NOT Primordial” does not appear in console. The application does appear and seems to work fine. My questions are: 1. For Application (Desktop), is there an alternative to the Application object that I can use for a single swf worker so that the worker loads and calls init()? 2. For TabbedViewNavigatorApplication is there a event which the worker can use (and maybe the main thread as well) to fire off the init function? Third, if this needs to be documented somewhere, I’d be glad to take ownership and edit a wiki or otherwise to help evangelize. Thanks <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" applicationComplete="init()"> <fx:Script> <![CDATA[ protected function init():void{ trace("Supported:" + Worker.isSupported); if(Worker.current.isPrimordial) { trace("isPrimordial"); var m_worker : Worker = WorkerDomain.current.createWorker(this.loaderInfo.bytes); m_worker.start(); } else trace("is NOT Primordial”); return; } ]]> </fx:Script> </s:Application>
