Hi,
I’m trying to load all the images to display on the stage from an xml file.
I am also trying to add them onto the stage using the Bitmap class. This is where I am having trouble. I am using the Bitmap class so I can use their width and height.
Right now I’m only able to see one image on stage when I use the Bitmap class. If I don’t use the Bitmap class and just addChild(iconLoader) inside the loop in the xmlLoaded function I can see all of the images. But I want to use the Bitmap class.
What am I missing or what am I doing wrong
Here is the code
package {
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.text.*;
public class Icon02 extends Sprite {
private var xml:XML;
private var xmlList:XMLList;
private var xmlLoader:URLLoader=new URLLoader;//creates a new URL loader. xmlLoader
private var iconLoader:Loader;//=new Loader();// // creates a new loader. iconLoader
private var i:int;
public function Icon02() {
xmlLoader.load(new URLRequest("Icon.xml"));//load Icon.xml
/*********************** Event handlers **********************/
xmlLoader.addEventListener(Event.COMPLETE,xmlLoaded);// xmlLoader complete call function xmlLoaded
}
function xmlLoaded(evt:Event):void {
xml=XML(evt.target.data);
xmlList=xml.children();
for (i=0; i < xmlList.length(); i++) {
iconLoader=new Loader() ;// creates a new loader. IconLoader
iconLoader.load(new URLRequest(xmlList*.attribute("icon")));//load icon from xml file
iconLoader.x = i * 50;
iconLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,iconLoaded);// iconlLoader complete call function iconlLoaded
//addChild(iconLoader);
}
}//xmlLoaded
function iconLoaded(evt:Event):void {
var image = Bitmap(evt.target.loader.content);
//image.x = i * 50;
addChild(image);
}
}//Icon02
}//package
Thanks
vxd