Hi all.
I ve googled for 2 days and still couldnt find a solution to my problem or even an example.
Here s my issue.
I have an XML file which contains a link to a photo file and a link to a text file.
Like this…
<?xml version=“1.0”?>
<news>
<new mythumb=“thumb01.jpg” mytext=“text01.txt” />
<new mythumb=“thumb02.jpg” mytext=“text02.txt” />
.
.
.
</news>
I m using a FOR loop to read the XML file
assigning the photo to a new MOVIECLIP eachtime.
//***************************************************************************
home = this;
var xml:XML = new XML();
xml.ignoreWhite = true;
xml.load (“myXML.xml”);
xml.onLoad = function () {
var nodes = this.firstChild.childNodes;
numOfItems = nodes.length;
for (var i=0;i<numOfItems;i++) {
var news = home.attachMovie(“entry”,“entry”+i,i+1);
news.news_pic.loadMovie(“news/”+nodes*.attributes.mythumb);
}
}
//***************************************************************************
Now the problem occured when i tried to include a LoadVars (for the text file) inside the FOR loop
//***************************************************************************
loadText = new LoadVars();
loadText.load(nodes*.attributes.mytext);
loadText.onLoad = function(success:Boolean) {
if(success) {
news.news_text.htmlText = this.my_news;
}else{
trace(“Error”);
}
}
//***************************************************************************
If I place the code inside the FOR loop as is, it only reads the last text file of XML
and the rest of the textfields are blank.
I tried some other ways but no luck.
i have either the first text correct, or the last or just “undefined”,
but always one of the text blocks. Never all of them.
The photos appear correctly every time.
Any ideas how I should do this ?
Thanks in advance