Question
Load images in the correct order, needs help..
I have tried loading in some images in the order of the xml files.. that contain them ..
they did load in one by one but .. in random order .. so mabe i am doing too much or too liitle can some one give it asecond look for me ..
//-- load Xml
urlLoader.load(new URLRequest("loader_alpabet/loader_alpabet.xml"));
urlLoader.addEventListener(Event.COMPLETE,xmlReady);
this.addEventListener(Event.ENTER_FRAME,entFrm);
// process the Xml and create array of objs
function xmlReady(evt:Event):void {
xml=new XML(evt.target.data);
var xmlListUrls:XMLList=new XMLList(xml.image.url.text());
var xmlListNames:XMLList=new XMLList(xml.image.name.text());
var xmlListDescs:XMLList=new XMLList(xml.image.description.text());
for (var g:Number = 0; g < xmlListNames.length(); g++) {
imagePack.push({name:xmlListNames,url:xmlListUrls,desc:xmlListDescs});
if (xmlListUrls.length()==imagePack.length) {
loaderMachine();
}
}
}
//this is where i position the images
function entFrm(evt:Event):void {
if (imageIcons.length>0) {
for (var g:Number = 0; g < imageIcons.length; g++) {
imageIcons.x=(centerX+Math.cos(angle+g)*radiusX)-imageIcons.width/2;
imageIcons.y=(centerY+Math.sin(angle+g)*radiusY)-imageIcons.height/2;
imageIcons.scaleX=imageIcons.scaleY= ((imageIcons.y/150) - 0.5);
stage.addChildAt(imageIcons, imageIcons.scaleX);
angle+=speed;
}
}
}
//-- loader function
function loaderMachine():void {
trace(imagePack.length);
loader = new Loader();
loader.load(new URLRequest(imagePack[count].url));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,imageReady);
}
// put image on stage
function imageReady(evt:Event):void {
var image:Bitmap = (Bitmap)(evt.target.content);
addChild(image);
imageIcons.push(image);
count++;
if (count<imagePack.length) {
loaderMachine();
}
} 