I’m trying positioning external loaded images from an XML and position them according to the stage dimensions.
Here’s what I’ve come so far: creating a loader for each image and then position them according to their size.
Is there any way to do this avoiding to create a multidimensional array (that’s to say two arrays one for the images name and one for the loaders)?
private function loadBg():void {
for each (var image:XML in xml.BG..IMG) {
var loader:Loader = new Loader();
loader.load(new URLRequest(image.@url));
loader.addEventListener(Event.COMPLETE, positionBg);
addChild(loader);
}
}
private function positionBg(e:Event):void {
.....
switch (?????) {
case "bg_br.jpg":
loader.x=stage.stageWidth-loader.width;
loader.y= stage.stageHeight-loader.height;
break;
case "bg_bl.jpg":
loader.x=stage.stageWidth-loader.width;
loader.y= stage.stageHeight-loader.height;
break;
case "bg_tr.jpg":
loader.x=stage.stageWidth-loader.width;
loader.y= 0;
break;
}
......
}