I have dynamic text boxes on my main timeline that I want to fill with XML data when the user clicks a button. The buttons are in a separate movie clip, and I have a for-each loop in the code for this movie clip that grabs the data. The problem is that the text boxes only display the last piece of data referenced in the loop.
Here is the XML:
<election>
<contest>
<Name>GOVERNOR</Name>
<Results>
<precinct code="cp2a">
<candidate name="Bob">1</candidate>
<candidate name="Joe">18</candidate>
<candidate name="Frank">88</candidate>
<candidate name="Lisa">0</candidate>
</precinct>
−
<precinct code=“cp2b”>
<candidate name=“Bob”>0</candidate>
<candidate name=“Joe”>18</candidate>
<candidate name=“Frank”>99</candidate>
<candidate name=“Lisa”>2</candidate>
</precinct>
</Results>
</contest>
</election>
And here is the relevant Flash code:
function showPrecinct (event:MouseEvent):void
{
var number=event.target.name
var electionInput:XML = xmlData;
var resultsList:XMLList = electionInput.contest.(Name == “GOVERNOR”).Results.precinct.(@code==number).candidate.text();
var namesList:XMLList = electionInput.contest.(Name == “GOVERNOR”).Results.precinct.(@code==number).candidate.attribute(“name”);
for each (var resultsElement:XML in resultsList) {
MovieClip(parent).Results_txt.text=resultsElement;
}
for each (var namesElement:XML in namesList) {
MovieClip(parent).Names_txt.text=namesElement;
trace(namesElement);
}
}
I can get all the names to show up in the output from the trace, but only Lisa shows up in the Names_txt text box.
Thanks for any help!