Passing XML data to LoadVars


[SIZE=1]I am working with XML structure similar to the following:[/SIZE]

[SIZE=1]<item num=“1” aname1=“John” aname2=“Doe” />[/SIZE]
[SIZE=1]<item num=“2” aname1=“Frank” aname2=“Smith” />[/SIZE]

[SIZE=1]I have defined the var aname2 on the main timeline as follows:[/SIZE]
[SIZE=1]var inv = inventory_xml.firstChild;[/SIZE]
[SIZE=1]var catalogitem = inv.childNodes;[/SIZE]
[SIZE=1]var aname2 = catalogitem*.attributes.aname2;[/SIZE]

[SIZE=1]I have also on the main Timeline a mc which holds a dynamic text field called [/SIZE][SIZE=1]statement_txt.[/SIZE]

[SIZE=1]I am trying to use LoadVars to load a text variable named “statement” from a text file[/SIZE]
[SIZE=1]which is named “stmt_”+aname2+".txt" into statement_txt.[/SIZE]

[SIZE=1]The following example just loads the John Doe text file into the mc:[/SIZE]

[SIZE=1]// Load text from artist statement txt file and assign it to statement_txt[/SIZE]
[SIZE=1]// while preserving HTML formatting within text variable[/SIZE]
[SIZE=1]statement_lv = new LoadVars();[/SIZE]
[SIZE=1]statement_lv.onLoad = onText;[/SIZE]
[SIZE=1]function onText() {[/SIZE]
[SIZE=1]statement_txt.html = true;[/SIZE]
[SIZE=1]statement_txt.htmlText = statement_lv.statement;[/SIZE]

[SIZE=1]I want to be able to change it so the word “Doe” in the filepath replaced with the variable aname2, so that:[/SIZE]

[SIZE=1]if(catalogitem*.attributes.aname2 == “Doe”) { [/SIZE]

[SIZE=1]…then load variable named “statement” from filepath /statements/stmt_Doe.txt, and:[/SIZE]

[SIZE=1][SIZE=1]if(catalogitem*.attributes.aname2 == “Smith”) { [/SIZE]

[SIZE=1]…then load variable named “statement” from filepath /statements/stmt_Smith.txt[/SIZE]

[/SIZE][SIZE=1]i tried something like:[/SIZE]

[SIZE=1]var a2 = “stmt_”+aname2+".txt";[/SIZE]

[SIZE=1]but it returned undefined.[/SIZE]

[SIZE=1]Any ideas? Thanks.[/SIZE]