Hi,
I have an XML file with 1 parent node that has 1 child node inside it. The parent node is straight forward. It only has one attribute.
The child node has 3 attributes in it - Title, Photo, URL
I want my Flash file to have 3 containers - 2 Text list containers and 1 image holder. The first text container will load all of the Names of parent node. The second text container will load all of the Title of the child node.
The 3rd container will be a MC holder that will load the Photo and will link it to the URL specified in child node.
How do I script my Flash file?
Right now, my script is as follows and it successfully loads the name from parent node in one of the containers. I’m confused with other two!
[LEFT][COLOR=#993300]function[/COLOR] onXmlLoaded[COLOR=#000000]([/COLOR]success:[COLOR=#993300]Boolean[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR]success[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#F000F0]*// make a handle to the root node in the xml*[/COLOR]
[COLOR=#993300]var[/COLOR] mainnode:[COLOR=#993300]XMLNode[/COLOR] = bannerxml.[COLOR=#993300]firstChild[/COLOR];
[COLOR=#F000F0]*// set up an array of all brand nodes*[/COLOR]
[COLOR=#993300]var[/COLOR] brandnodes:[COLOR=#993300]Array[/COLOR] = bannerxml.[COLOR=#993300]firstChild[/COLOR].[COLOR=#993300]childNodes[/COLOR];
[COLOR=#993300]for[/COLOR] [COLOR=#000000]([/COLOR][COLOR=#993300]var[/COLOR] i:[COLOR=#993300]Number[/COLOR] = [COLOR=#000000]0[/COLOR]; i < brandnodes.[COLOR=#993300]length[/COLOR]; i++[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#F000F0]*// for each brand node:*[/COLOR]
[COLOR=#993300]var[/COLOR] productnode:[COLOR=#993300]XMLNode[/COLOR] = brandnodes[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR];
brand.[COLOR=#993300]push[/COLOR][COLOR=#000000]([/COLOR]
[COLOR=#000000]{[/COLOR]i:i+[COLOR=#000000]1[/COLOR],
bname:brandnode.[COLOR=#993300]attributes[/COLOR].[COLOR=#993300]name[/COLOR],
[COLOR=#000000]}[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
setup[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR] [COLOR=#993300]else[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#993300]trace[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000FF]'error reading XML'[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]
[COLOR=#993300]function[/COLOR] setup[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#F000F0]*// set up choosebrand listbox*[/COLOR]
choosebrand.[COLOR=#000000]labelField[/COLOR] = [COLOR=#0000FF]"bname"[/COLOR];
choosebrand.[COLOR=#000000]dataProvider[/COLOR] = banner;
choosebrand.[COLOR=#000000]addEventListener[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000FF]"change"[/COLOR], Delegate.[COLOR=#000000]create[/COLOR][COLOR=#000000]([/COLOR][COLOR=#993300]this[/COLOR], loadScreen[COLOR=#000000])[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
[/LEFT]
Any help would be much appreciated!
Thanks,
Sudarshan