Hi,
I am trying to load a series of images into a MC using XML to provide URLs and other image data. The ultimate goal is to place each image (as a sprite?) in it’s correct position in a MC, assign it an instance name and make it into a simple button. This button would then be used to load a large version of the image.
I can make the images appear on the stage I expect they are only being put into the Display List, but cannot seem to be able to position them at a specific point taken from the ‘xpos’ and ‘ypos’ XML data, assign an instance name or make them a button.
The code I have so far is:
//Variables Set
var sect1loaded:Number = 0;
var sectionNum:Number = 1;
var imageNum:String = sectionNum + "_";
var sectionImagecount: Number = 13;
var imagename;
/* XML LOADING */
var openingData: XML
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE,loadXMLcomplete);
loader.load(new URLRequest("images_1.xml"));
// LOOP to load images from Each at a different poition taken from XML
function loadXMLcomplete(e:Event):void {
openingData = new XML(e.target.data);
for (var i:Number = 1; i < sectionImagecount + 1; i++) {
var my_loader:Loader = new Loader();
my_loader.load(new URLRequest(openingData.image.(attributes()[0] == imageNum + i).small_url.*));
my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded,false,0,true);
imagename = imageNum +i;
trace(openingData.image.(attributes()[0] == imageNum + i).small_url.*);
}
loader.removeEventListener(Event.COMPLETE, loadXMLcomplete);
sect1loaded = 1;
}
function loaded(evt:Event):void{
addChild(evt.target.content).name = imagename;
imagename.x = openingData.image.(attributes()[0] == imagename).xpos.*;
imagename.y = openingData.image.(attributes()[0] == imagename).ypos.*;
}
Ideally what I believe I need to do is create a separate class for the image load which can then be used over and over again when needed… I will crack this when I have the core principles hacked.
Am I on the right track? where am I going wrong?
Any pointers / help much appreciated.
Andrew