I’m trying to search in more then 1 XML files but I’m doing something wrong! if I indert a value to find - I have to press search 2 times that it finds it?!? the first time it finds “undefined”
please HELP! what am I doing wrong(look at the attached files)
var found;
var searchFiles:Array = [“washbasins.xml”, “bathtubs.xml”];
//
function searchXML(searchVar) {
for (var j = 0; j<searchFiles.length; j++) {
var s:XML = new XML();
s.ignoreWhite = true;
s.load(searchFiles[j]);
s.onLoad = function() {
var searchCurrent:Array = this.firstChild.childNodes;
for (var i = 0; i<searchCurrent.length; i++) {
if (searchVar == searchCurrent*.attributes.item_txt) {
found = searchCurrent*.attributes.item_txt;
//trace(searchCurrent*.attributes.item_txt);
//trace(searchCurrent*.attributes.url);
break;
}
}
};
}
}
search_btn.onRelease = function() {
if (!search_txt.text) {
trace(“insert value”);
} else {
searchXML(search_txt.text);
trace(" "+found);
//here i should check if nothing is found
}
};