Flex SWFs must be on-stage in order to load. Are you worried about missing an ADD_TO_STAGE event? Maybe send a fake one on applicationComplete.
On 5/13/10 7:51 AM, "jmbo...@bellsouth.net" <jim_bo...@premierinc.com> wrote: Alex, Your suggestion will work and in fact, that is the way we were doing it. Unfortunately, we needed to create a Robotlegs context so that we can listen for ADD_TO_STAGE events and allow it to automatically mediator our view components (see below). That is why I added the sub-app as a child later. Any other ideas how to make the current code work? // Inject dependencies into the module and initiate the context since autoload is set var subApp:IModule = event.moduleApp; injector.injectInto(subApp); // Make sure the content fills the page var subAppComponent:SubAppBase = SubAppBase(subApp); subAppComponent.percentHeight = 100; subAppComponent.percentWidth = 100; /* Add to contentViewStack here based upon position Simply add as a child to the stub canvas that already exists for the module */ var index:int = _moduleArray.getItemIndex(swf); var canvas:Canvas = Canvas(contentViewStack.getChildAt(index)); canvas.addChild(subAppComponent); --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , Alex Harui <aha...@...> wrote: > > Try adding the SWFLoader to the canvas before you load it. > > > On 5/12/10 12:40 PM, "jmbo...@..." <jim_bo...@...> wrote: > > > > > > > Hi, > > I am experiencing an odd problem and I hope someone knows why. I am loading > a sub-application using SWFLoader. I listen for the Event.COMPLETE command. > Once the swf is loaded, I then add a listener to the SystemManager for the > swf and listen for the FlexEvent.APPLICATION_COMPLETE event. At that point, > I add the application as a child to a Canvas that exists in a view stack (see > code below). This is great, the content loads, but it doesn't seem to load > correctly. The legends in my charts are not oriented the way they should be > and whenever I roll over an item with a tooltip, I get errors like the > following error: > > TypeError: Error #1009: Cannot access a property or method of a null object > reference. > at mx.managers::SystemManager/get > toolTipChildren()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\managers\SystemManager.as:1178] > at > mx.charts.chartClasses::ChartBase/updateDataTipToMatchHitSet()[C:\work\flex\dmv_automation\projects\datavisualisation\src\mx\charts\chartClasses\ChartBase.as:3030] > > Does anyone have any clue what is going on?????? Thanks, > > Jim > > !!!!!!!!!! snippet where swf is loaded !!!!!!!!!!!! > > ...... > var loader:SWFLoader = null; > if (content.contentType == ContentData.SWF) > { > var uri:String = content.contentUri; > > var loaderContext:LoaderContext = new LoaderContext(); > loaderContext.applicationDomain = ApplicationDomain.currentDomain; > loaderContext.securityDomain = SecurityDomain.currentDomain; > > /* Create the swf loader and add it as a child to a canvas > * so that it will have a place to display on the display list > */ > loader = new SWFLoader(); > loader.scaleContent = true; > loader.loaderContext = loaderContext; > loader.addEventListener(Event.COMPLETE, onLoadingComplete); > loader.addEventListener(IOErrorEvent.IO_ERROR, onModuleLoadError); > loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onModuleLoadError); > loader.load(uri); > ..... > > private function onLoadingComplete(event:Event):void > { > var swfLoader:SWFLoader = event.currentTarget as SWFLoader; > if (swfLoader != null && swfLoader.content != null) > { > /* Create an annoymous listener that dispatches an event when the module is > ready to show */ > sm.addEventListener(FlexEvent.APPLICATION_COMPLETE, > function(flexEvent:FlexEvent):void > { > var cmEvent:ContentManagementEvent = new > ContentManagementEvent(ContentManagementEvent.CONTENT_READY_TO_SHOW); > cmEvent.moduleLoader = swfLoader; > // Grab a reference to the module application itself > if (flexEvent.currentTarget.application is IModule) > { > cmEvent.moduleApp = flexEvent.currentTarget.application as IModule; > } > dispatch(cmEvent); > > }); > } > } > } > > !!!!!!!!!! snippet when adding to Canvas !!!!!!!!!!!! > > if (event.moduleApp != null) > { > Logger.debug("Setting parentInjector and starting the RL context for :" + > moduleId); > > // Make sure the content fills the page > var subAppComponent:SubAppBase = SubAppBase(subApp); > subAppComponent.percentHeight = 100; > subAppComponent.percentWidth = 100; > > /* Add to contentViewStack here based upon position > Simply add as a child to the stub canvas that already > exists for the module > */ > var index:int = _moduleArray.getItemIndex(swf); > var canvas:Canvas = Canvas(contentViewStack.getChildAt(index)); > > canvas.addChild(subAppComponent); > } > > > > > > > -- > Alex Harui > Flex SDK Team > Adobe System, Inc. > http://blogs.adobe.com/aharui > -- Alex Harui Flex SDK Team Adobe System, Inc. http://blogs.adobe.com/aharui