Hai,
For my work i’m trying to get an Array properly into a text field. The array is being taken out of XML and then turned into the array and fed into a textfield. But it shows up like this:
Name1, Name2, Na
me4, Name4, Name5
But i want it to show up like
Name1
Name2
Name3
Name4
How could I achieve this?
This is my code:
var xml = new XML();
xml.ignoreWhite = true;
xml.onLoad = function() {
var score, name, time, position;
score = this.firstChild;
if(score.hasChildNodes()) {
var name = new Array();
var time = new Array();
for(var i = 0; i < score.childNodes.length; i++) {
name* = score.childNodes*.childNodes[0].childNodes[0].nodeValue;
time* = score.childNodes*.childNodes[1].childNodes[0].nodeValue;
position = i+1;
//naam_txt.text = position + “: " + name + " – " + time + " sec.”
naam_txt.text = name;
tijd_txt.text = time;
//trace(score.childNodes*.childNodes[0].childNodes[0]);
//trace(position + “: " + name + " – " + time + " sec.”);
}
}
}
xml.load(“tijden.xml”);
//xml.load(“http://gigakids.nl/files/save.php”);
/*var uitslag_array;
var scoren_xml = new XML();
scoren_xml.ignoreWhite = true;
scoren_xml.onLoad = function(succes){
if(succes){
var score = this.firstChild;
var name, time, position;
uitslag_array = scoren.childNodes;
PopulateLists(uistlag_array);
}else{
trace("Dat gaat zo niet goed he!")
}
}
scoren_xml.load(“http://gigakids.nl/files/save.php”);
PopulateLists = function(xml_array){
naam_txt.text = tijd_txt.text = “”;
for (var i=0; i<xml_array.length; i++){
name = score.childNodes*.childNodes[0].childNodes[0];
time = score.childNodes*.childNodes[1].childNodes[0];
var ding = xml_array*.attributes;
naam_txt.text = ding.name + "
"
tijd_txt.text = ding.time + "
"
trace(name + " – " + time + " sec.");
}
}*/
var uitslag_array
var xml = new XML();
xml.ignoreWhite = true;
xml.onLoad = function() {
var score, name, time, position;
score = this.firstChild;
uitslag_array = score.childNodes;
if(score.hasChildNodes()) {
for(var i = 0; i < score.childNodes.length; i++) {
var scoren = uitslag_array*.attributes;
naam_txt.text = scoren.name + "
“;
name = score.childNodes*.childNodes[0].childNodes[0];
time = score.childNodes*.childNodes[1].childNodes[0];
position = i+1;
naam_txt.text = name
tijd_txt.text = time + " sec.”
//naam_txt.text = position + “: " + name + " – " + time + " sec.”
trace(position + “: " + name + " – " + time + " sec.”);
}
}
}
xml.load(“http://gigakids.nl/files/save.php”);
Thanks in advance for your help!
And yes, i have searched the forum.
Bye!