# \[AS2.0/XML\] multi dimensional array from XML - nodes keep swapping

**URL:** <https://forum.kirupa.com/t/as2-0-xml-multi-dimensional-array-from-xml-nodes-keep-swapping/253619>\
**Category:** flash\
**Created:** [March 3, 2008, 3:53pm UTC](https://forum.kirupa.com/t/as2-0-xml-multi-dimensional-array-from-xml-nodes-keep-swapping/253619 "2008-03-03T15:53:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DadoTech](https://avatars.discourse-cdn.com/v4/letter/d/c57346/32.png) [@DadoTech](https://forum.kirupa.com/u/DadoTech)\
**Post date:** [March 3, 2008, 3:53pm UTC](https://forum.kirupa.com/t/as2-0-xml-multi-dimensional-array-from-xml-nodes-keep-swapping/253619/1 "2008-03-03T15:53:53Z")

</div>

I’ve been trying to resolve this for a while now…

[COLOR=DarkRed]Images I am loading from XML are associated with the right record on first load but then on refresh they swap places !!! WHY!? :-/[/COLOR]

I am loading XML and creating arrays.

Then I pass the array data to objects using loop functions.

the AS counts how many books there are in total then and creates the objects and passes informations regarding each book into the individual objects.

when I trace the array data just before starting the loop function I get a good consistent read:

\>  
[COLOR=DarkOrange]Images:[/COLOR]images/Gordon\_Ramsays\_Sunday\_Lunch.jpg,images/Easy\_Italian.jpg,images/Healthy\_Foods.jpg  
[COLOR=DarkOrange]Text: [/COLOR]Gordon Ramsay’s Sunday Lunch,Easy Italian,Healthy Food  
[COLOR=DarkOrange]Links:[/COLOR] Gordon Ramsay’s Sunday Lunch link,Easy Italian link,Healthy Food link  
[COLOR=DarkOrange]Prices:[/COLOR] £19.99 hardback,£8.99 paperback,£8.99 paperback output  
\>

so the XML loading is not the problem.

Is it something to do with the way I am using ‘loadClip();’

This is the code building the page:

//---------------------------------------------------------  
/\*

- This frame we will build the navigation  
_/  
stop();  
//  
trace("Images: "+astrImages);  
trace("Text: "+astrText);  
trace("Links: "+astrLinks);  
trace("Prices: "+astrPrice);  
//  
for (var i = 0; i\<nTotalButtons; i++) {  
navHolder\_mc.createEmptyMovieClip(“navButton”+i,i);  
// make new MovieClip and set to newly created button  
var navButton:MovieClip = navHolder\_mc[“navButton”+i];  
// load images  
image\_mcl.loadClip(astrImages_,navButton);  
}

// Invoked when the actions on the first frame of the loaded clip have been executed  
mclListener.onLoadInit = function(target\_mc:MovieClip) {  
// add link property  
target\_mc.linkURL = astrLinks[nCounter];  
// add events  
target\_mc.onPress = buttonClick;  
//  
var bookImgHeight:Number = target\_mc.\_height;  
var bookImgWidth:Number = target\_mc.\_width;  
//reposition the new istance of the book object  
target\_mc.\_y = Math.round(yPosition);  
yPosition += bookImgHeight+10;  
//  
//–title text–  
// place the text  
target\_mc.createTextField(“titleText”,nCounter,130,0,400,30);  
// set properties of title text  
target\_mc.titleText.border = false;  
target\_mc.titleText.selectable = false;  
target\_mc.titleText.wordWrap = true;  
target\_mc.titleText.styleSheet = my\_css;  
target\_mc.titleText.htmlText = “\<.buttonStyle\>”+astrText[nCounter]+"\</.buttonStyle\>";  
// reposition the price text  
target\_mc.titleText.autoSize = true;  
var nMiddle:Number = (bookImgHeight/2);  
target\_mc.titleText.\_y = nMiddle-(target\_mc.titleText.\_height/2+60);  
//  
//  
//–price text–  
// place the text  
target\_mc.createTextField(“priceText”,nCounter+1,130,0,200,30);  
// set properties of price text  
target\_mc.priceText.border = false;  
target\_mc.priceText.selectable = false;  
target\_mc.priceText.wordWrap = true;  
target\_mc.priceText.styleSheet = my\_css;  
target\_mc.priceText.htmlText = “\<.priceStyle\>”+astrPrice[nCounter]+"\</.priceStyle\>";  
// reposition the price text  
target\_mc.priceText.autoSize = true;  
var nMiddle:Number = (bookImgHeight/2);  
target\_mc.priceText.\_y = nMiddle-(target\_mc.priceText.\_height/2+30);  
//  
//  
nCounter += 1;  
};  
image\_mcl.addListener(mclListener);  
//---------------------------------------------------------

this the simple XML code:

[http://www.thecliffsoncape.com/xml\_test\_site1/navigation.xml](http://www.thecliffsoncape.com/xml_test_site1/navigation.xml)

this the test site:

[http://www.thecliffsoncape.com/xml\_test\_site1/navigation\_Flash8.html](http://www.thecliffsoncape.com/xml_test_site1/navigation_Flash8.html)

load once, notice the position of the book covers.  
load again, it al goes swappy !!

\*\*HELP PLEASE!

\*\*thank you.
