W_Burner
01-28-2006, 10:32 PM
I want to make a menu out of an xml file. To build the menu I use an array but when I want to make an array out of the xml-file and call for the different value to go in to a textfield, the value is 'undefined'. However, when I use the trace function instead of the textfield, the value is correct. What am i doing wrong.
This is what i want to make:
my_array[0] = new Array("Home","index.php?section=home","_top");
my_array[1] = new Array("Contact","index.php?section=contact","_top");
etc...
when i just type this out, everything works correct. I call for the array using 'links.my_txt1.htmlText = my_array[i][0];'
But, when I use:
menu= new XML();
menu.ignoreWhite = true;
menu.onLoad = function(success) {
if (success) {
_global.my_array = [];
for (var i = 0; i<menu.firstChild.childNodes.length; i++) {
_global.my_array[i] = [];
_global.my_array[i][0] = menu.firstChild.childNodes[i].attributes.name;
_global.my_array[i][1] = menu.firstChild.childNodes[i].attributes.link;
_global.my_array[i][2] = menu.firstChild.childNodes[i].attributes.target;
trace(_global.my_array[i][0] +" | "+_global.my_array[i][1]+" | "+_global.my_array[i][2]);
}
}
};
When I do this:
trace(_global.my_array[i][0]);
links.my_txt1.htmlText = _global.my_array[i][0];
the trace works but the texfield doesn't!!! What am i doing wrong???
This is what i want to make:
my_array[0] = new Array("Home","index.php?section=home","_top");
my_array[1] = new Array("Contact","index.php?section=contact","_top");
etc...
when i just type this out, everything works correct. I call for the array using 'links.my_txt1.htmlText = my_array[i][0];'
But, when I use:
menu= new XML();
menu.ignoreWhite = true;
menu.onLoad = function(success) {
if (success) {
_global.my_array = [];
for (var i = 0; i<menu.firstChild.childNodes.length; i++) {
_global.my_array[i] = [];
_global.my_array[i][0] = menu.firstChild.childNodes[i].attributes.name;
_global.my_array[i][1] = menu.firstChild.childNodes[i].attributes.link;
_global.my_array[i][2] = menu.firstChild.childNodes[i].attributes.target;
trace(_global.my_array[i][0] +" | "+_global.my_array[i][1]+" | "+_global.my_array[i][2]);
}
}
};
When I do this:
trace(_global.my_array[i][0]);
links.my_txt1.htmlText = _global.my_array[i][0];
the trace works but the texfield doesn't!!! What am i doing wrong???