0

I'm loading multiple swfs into a container swf, how do I decide which is on top of the other? Currently I'm loading a swf like this:

var myLoader:Loader = new Loader();
var url:URLRequest = new URLRequest("example.swf");

myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressListener);
function progressListener (e:ProgressEvent):void{
if (e.bytesLoaded == 0){
    //Upload loading status to zero
}else{
    //Upload loading status
}
}

myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, startListener);
function startListener (e:Event):void{
addChild(myLoader.content);
}

myLoader.load(url);
Cœur
  • 37,241
  • 25
  • 195
  • 267
James T
  • 3,292
  • 8
  • 40
  • 70

1 Answers1

1

Currently the order in which they are drawn to the screen depends on which file completes loading first.

You could either download the swf file you want in the foreground, after the other one is loaded:

function startListener(e:Event):void
{
    addChild(myLoader.content);
    myLoader.load("url_of_the_swf_in_front");
}

or you could change the z-index afterwards:

stage.setChildIndex(foregroundSwf, stage.numChildren -1);
RC-1290
  • 595
  • 6
  • 10
  • I just found out you could also use `addChildAt(content, index)` – James T Oct 25 '11 at 00:39
  • 1
    @bubby4j you can indeed, by explicitly placing the background sprite in the background. But if you only explicitly place the foreground swf in the foreground, it might still be in the background, if it finishes before the background does. – RC-1290 Oct 25 '11 at 08:24