Help with xml please!

i have a bit of code that gets information from an xml file and loads it into a movie clip that i made. this works great for one result, but i want it to keep going so it duplicates the movie clip and brings out the other results. so far ive been able to duplicate the movie clip and place it at x & y co ords coming from the xml. but the rest of the information isnt coming through. any help would be great.

This is the code i have at the moment.
myXML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function(){
imageList = this.firstChild.childNodes;
showImages(imageList);
}
myXML.load(“gallery1.xml”);

function showImages(list:Array){

for(i=0;i<list.length;i++){
imageFile = list*.attributes.url;
nametxt = list*.attributes.title;
phonetxt = list*.attributes.phone;
yval = list*.attributes.yval;
xval = list*.attributes.xval;

info.name_txt.text = nametxt;
info.address_txt.text = address;
info.phone_txt.text = phonetxt;

info.picture.loadMovie(imageFile);
info._x = xval;
info._y = yval;
trace(nametxt);

info.duplicateMovieClip(“info_”+i, i+1);
}
}

Thanks

gvp16

You really shouldnt be rolling this way in AS3.

Use the E4X syntax the Adobe Devs have blessed you with.

Gimme the structure of the XML and i’ll show you how to E4X reference that puppy.

[quote=Ikinsey;2328249]You really shouldnt be rolling this way in AS3.

Use the E4X syntax the Adobe Devs have blessed you with.

Gimme the structure of the XML and i’ll show you how to E4X reference that puppy.[/quote]

ive never heard of E4X, ive only just started using XML and dont know much about it.
this is the xml im using.

<gallery>
<image url=“http://www.gvperkins.com/images/glyn.jpg” title=“Glynneath” phone=“11111111111” xval=“290” yval=“90”/>
<image url=“http://www.gvperkins.com/images/swan.jpg” title=“Swansea” phone=“00000000000” xval=“50” yval=“150”/>
</gallery>

Thanks.

E4X is a way of operating on and sifting through XML with simple syntax.
You should go through your XML as follows:


//the .. in myXML..image means find all image nodes in MyXML (regardless of how nested)
//this for each loop will go through each image node
for each(var image:XMLNode in myXML..image)
{
     //DO STUFF HERE on each image node
     //use image.@attributeName to access the attributes of the node 
     //(ie: image.@xval will get the value of xval for this node).
}

sorry but i havent got a clue what to do with that, wot ive got for the xml works fine, its the flash thats giving me probs, however ive figured out what i need to do, just dont know how to do it. (see below).

myXML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function(){
imageList = this.firstChild.childNodes;
showImages(imageList);
}
myXML.load(“gallery1.xml”);

function showImages(list:Array){

for(i=0;i<list.length;i++){
imageFile = list*.attributes.url;
nametxt = list*.attributes.title;
phonetxt = list*.attributes.phone;
yval = list*.attributes.yval;
xval = list*.attributes.xval;

info.duplicateMovieClip(“info_”+i, i+1); [COLOR=red]on this line is the variable ’ i ’ [/COLOR]
info.name_txt.text = nametxt; [COLOR=red]------ what i need to do is add the variable i to this instance name, making it info_1 then info_2 etc…[/COLOR]
info.address_txt.text = address; [COLOR=red]simply adding it, eg info+i doesnt seem to work :m:[/COLOR]
info.phone_txt.text = phonetxt;

info.picture.loadMovie(imageFile);
info._x = xval;
info._y = yval;
trace(nametxt);

}
}

BTW im using action script 2.

BTW im using action script 2.

Well, there’s your problem.

Ha, but I think this might help you:

In AS2 the syntax this[“info_”+i] allows you to do dynamic references. Any combination of
parent[childInstanceName:String] works.

ye thanks, sorted it now.