Multiple Netconnection Load Order

Hi All,

Am hoping someone can help me here as I’m finding this problem quite difficult to resolve, yet the answer is no doubt quite simple. I’m loading some layers of data into flash using the netconnection object, looping through an array of user selected layernames to decide which layers to load. There as on average around 5 or 6 net connections created by a loop like so :

var i:Number = 1;

for each(var r in activeLayers) {

var gw:NetConnection = new NetConnection();
gw.connect(“http://mygateway.com/myurl.html”);
var res:Responder = new Responder(this.onResult,this.onFault);
gw.call(“LayerData.getData”, res, vars.params);
i++;

}

the vars.params is just an array of params relating to what data to return.

All of the netconnection objects complete, and data gets returned, but as the amount of data returned in each stream varies, the order in which the connections complete is different to the order of the layernames array. It would be fine for these connections to happen one at a time, and I think that may be the key, but how do I make the loop wait for the previous net connection to complete before launching the next? Eventhandler, listener, or do while loop? i cant seem to get any of those to work.

Dave