I have a parent movie that can load various “overlays”, which are externally loaded swf’s. For several of these overlays now, when the overlay is loaded into the parent movie, any components it was using seem to disappear, or more precisely, use the parent movie’s component (so if the parent movie doesn’t have an instance of whatever component it is in it’s library, then the child won’t display anything.) I have been able to (sort of) solve the problem by creating an instance of whatever component it is in the parent, but this is undesirable, especially since different overlays may use different versions of the same component (i.e., skinned UIScrollbars.)
So, code in the parent:
public function drawOverlay (rID:String, payload:String, x1:Number, y1:Number, w:Number, h:Number, o:Number, bg:String, bc:String, bw:Number) : void
{
trace("SKIN - "+rID,x1,y1,w,h,o,bg,bc,bw);
var loader:Loader = new Loader();
var overlayData:Object = {rID:rID,x1:x1,y1:y1,w:w,h:h};
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, this.onOverlayLoaded(overlayData));
var context:LoaderContext;
if (this.loaderInfo.url.indexOf('http') == 0) {
context = new LoaderContext(true,ApplicationDomain.currentDomain,SecurityDomain.currentDomain);
}
else {
context = new LoaderContext(false, ApplicationDomain.currentDomain);
}
loader.load(new URLRequest(payload), context);
}
}
private function onOverlayLoaded(overlayData:Object) : Function
{
var overlays = this.overlays;
var classRef = this;
return function(evt:Event) : void {
var loadedContent:DisplayObject = evt.target.content;
overlays[overlayData.rID] = loadedContent; //new MovieClip();
overlays[overlayData.rID].visible = false;
overlays[overlayData.rID].x = overlayData.x1;
overlays[overlayData.rID].y = overlayData.y1;
addChild(overlays[overlayData.rID]);
evt.target.removeEventListener(Event.COMPLETE, arguments.callee);
}
}
The child runs perfectly standalone (of course), and everything except components work fine when loaded. Everything is CS4/AS3. It seems like I have a rooting issue, where the root of the loaded swf is being linked to the root of the parent, but I don’t know what to check out…
Going bonkers with this - we can’t figure it out - Thanks!