Returning values for XML nodes

Hello people…

I’m trying to return values from my XML in order to attach a movie. Basically when a slide chages it calls a movie from the library.

I have got this far - which looks bloated to me:

function parse():Void {
if (xmlData.firstChild.nodeName == "girls") {
var rootNode:XMLNode = xmlData.firstChild;
for (i=0; i<rootNode.childNodes.length; i++) 
{
if (rootNode.childNodes*.nodeName == "slide") {
    
 trace ("slide_1")
 
 }
 
 if (rootNode.childNodes*.nodeName == "slide2") {
    
 trace ("slide_2")

 }
 
  if (rootNode.childNodes*.nodeName == "slide3") {
    
 trace ("slide_3")

 }
 
  if (rootNode.childNodes*.nodeName == "slide4") {
    
 trace ("slide_4")}
 
  if (rootNode.childNodes*.nodeName == "slide5") {
    
 trace ("slide_5")}
 
  if (rootNode.childNodes*.nodeName == "slide6") {
    
 trace ("slide_6")}
}}}

The fuction ‘parse’ is called initially when I’m loading the XML.

No in the output panel I get slide1,slide2,slide3 etc. This made me very happy! Except obviously if I try and extend the function and call the movieclips using attachMovie, it’s going to try and call them all at once :stare:.

How to a differentiate between slides now. What is my next step?

Any help, pointers or if I’m in the wrong area completely - let me know!

Thanks as always!

Chris

dont use a for loop here. use for loop only to parse the xml and store the data in a array.

function parse():Void {
if (xmlData.firstChild.nodeName == “girls”) {
var rootNode:XMLNode = xmlData.firstChild;

for (i=0; i<rootNode.childNodes.length; i++)
{
array.push(rootNode.childNodes*.nodeName);
}

later keep a counter variable set to 0;

and then over a time interval load data from the array using myarray[counter] and use it for attaching movieclip if you want.

Thank you sparkdemon for your input. But I haven’t got a clue how to proceed :crying:. Setting up the array sounds like a grand idea - but aren’t I effectively setting up two arrays?

I already have on array - which is the XML. So we’re effectively pushing one array onto another?

Forgive me - could you elaborate a little further for me…

Chris

my pleasure… just say what you need… to go with :slight_smile:

[quote=chrissyb;2333769]Thank you sparkdemon for your input. But I haven’t got a clue how to proceed :crying:. Setting up the array sounds like a grand idea - but aren’t I effectively setting up two arrays?

I already have on array - which is the XML. So we’re effectively pushing one array onto another?

Forgive me - could you elaborate a little further for me…

Chris[/quote]

Hello

Basically I want to attach a different movie from the library - when my xml slide changes. It is so I can have animated titles for the pictures.

So in my first post I could trace each node of the xml, but it’s how to turn this value into an action to call a movie clip.

later keep a counter variable set to 0;

and then over a time interval load data from the array using myarray[counter] and use it for attaching movieclip if you want.
I honestly don’t know how to achieve this. Here is a shot…

function parse():Void {
if (xmlData.firstChild.nodeName == "girls") {
var rootNode:XMLNode = xmlData.firstChild;
}
for (i=0; i<rootNode.childNodes.length; i++)

myArray.push(rootNode.childNodes*.nodeName);
}

trace(myArray.length);

if (myArray [x])

{_this.attachMovie("mcgirl1", "girl_mc", this.getNextHighestDepth(), {_x:Stage.width / 2, _y:Stage.height / 2});

}

This doesn’t work, but i gave it a go. I don’t understand if we already have the XML as effectively an array we need to create another one.

That is I THINK why I’m asking for help!!! Thanks sparkdemon…

Chris