I have a flash file that imports multiple images and places them on the stage. I want the images to be resized to the same, smaller size. However, the AS3 I am using is only resizing one of the images and hiding the others. My code is below:
var myXML:XML;
var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest("photos.xml"));
myLoader.addEventListener(Event.COMPLETE, processXML);
var xmlList:XMLList;
var dataLoader:Loader;
function processXML(event:Event):void
{
myXML = XML(event.target.data);
xmlList = myXML.children();
for(var i:int =0; i < xmlList.length(); i++) {
dataLoader = new Loader();
dataLoader.load(new URLRequest(xmlList*.filename));
trace ("Image loaded: " + (i+1));
dataLoader.x = i * 100 + 0;
dataLoader.y = 0;
dataLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, resizeImg);
}
}
function resizeImg(evt:Event){
var loader:Bitmap = evt.target.loader.content as Bitmap;
addChild(loader);
loader.width = 30;
loader.height = 30;
loader.x = 10;
loader.y = 10;
}
So how do I apply the resizeImg function to all images loaded from the xml file?