Hey guys.
I’m wondering if you could give me a hand. I’m trying to import some text from an XML file in to an SWF. It’s nothing too crazy. I’m trying to make a high score setup for a digital signage system.
The SWF will show 10 high scores with initials. I have 20 dynamic text fields. 10 for initials named n1_txt through n10_txt and 10 for scores called s1_txt through s10_txt.
Here is the actionscript I am using in Flash CS6:
var xmlData:XML = new XML();
var theURL_ur:URLRequest = new URLRequest("joust_test.xml");
var loader_ul:URLLoader = new URLLoader(theURL_ur);
loader_ul.addEventListener("complete", fileLoaded);
function fileLoaded(e:Event):void
{
xmlData = XML(loader_ul.data);
n1_txt.text = xmlData.name1;
n2_txt.text = xmlData.name2;
n3_txt.text = xmlData.name3;
n4_txt.text = xmlData.name4;
n5_txt.text = xmlData.name5;
n6_txt.text = xmlData.name6;
n7_txt.text = xmlData.name7;
n8_txt.text = xmlData.name8;
n9_txt.text = xmlData.name9;
n10_txt.text = xmlData.name10;
s1_txt.text = xmlData.score1;
s2_txt.text = xmlData.score2;
s3_txt.text = xmlData.score3;
s4_txt.text = xmlData.score4;
s5_txt.text = xmlData.score5;
s6_txt.text = xmlData.score6;
s7_txt.text = xmlData.score7;
s8_txt.text = xmlData.score8;
s9_txt.text = xmlData.score9;
s10_txt.text = xmlData.score10;
}
Here is the XML structure:
<?xml version="1.0" encoding="utf-8"?>
<joust>
<first>
<name1>BBH</name1>
<score1>515250</score1>
</first>
<second>
<name2>BBH</name2>
<score2>250600</score2>
</second>
<third>
<name3>MRM</name3>
<score3>239050</score3>
</third>
<fourth>
<name4>n/a</name4>
<score4>229800</score4>
</fourth>
<fifth>
<name5>REI</name5>
<score5>215500</score5>
</fifth>
<sixth>
<name6>CTS</name6>
<score6>177650</score6>
</sixth>
<seventh>
<name7>JTK</name7>
<score7>175150</score7>
</seventh>
<eighth>
<name8>JTK</name8>
<score8>173900</score8>
</eighth>
<ninth>
<name9>ACH</name9>
<score9>171900</score9>
</ninth>
<tenth>
<name10>ZAQ</name10>
<score10>153110</score10>
</tenth>
</joust>
The SWF doesn’t load any text when I am testing it on my desktop. The SWF and XML are both on the desktop.
Can someone help me figure out what I may be doing wrong?
Thanks!
Jeremy