This looks like exactly what i need.....I'm just not sure as to how i am going to implement it into my existing script. Here is what i have sitting on the frame currently. This is all of the code that i am using with in my flash file to search the xml file and display the information into a text box. Any further help would be greatly appreciated, im really stuck on this part of the project and haven't been able to move forward for a day or so.
Thanks!
String.prototype.contains = function(searchString) {
return (this.indexOf(searchString) != -1);
}
Array.prototype.contains = function(searchValue) {
var i = this.length;
while(i--) if (this[i] == searchValue) return true;
return false;
}
_global.empRangeValue;
var posts_xml = new XML();
posts_xml.ignoreWhite = true;
posts_xml.onLoad = function(success:Boolean):Void {
if (!success)
results_txt.text = "Error loading XML";
}
posts_xml.load("city.xml");
// create three XML nodes using createElement()
var citydataElement:XMLNode = posts_xml.createElement("City_Data");
var companyElement:XMLNode = posts_xml.createElement("Company");
var addressElement:XMLNode = posts_xml.createElement("Street_Address");
var phoneElement:XMLNode = posts_xml.createElement("Phone_Number");
// place the new nodes into the XML tree
posts_xml.appendChild(citydataElement);
citydataElement.appendChild(companyElement);
citydataElement.appendChild(addressElement);
citydataElement.appendChild(phoneElement);
SearchXML = function(nodes) {
var resultset = [];
var numnodes = nodes.length;
for (var i = 0; i < numnodes; i++) {
if (isMatch(nodes[i])) {
resultset.push(nodes[i]);
}
}
return resultset;
}
isMatch = function(currNode) {
var matching = true;
var NAICSlow = 0;
var NAICShigh = 100000;
try
{
if (search_fields.naics_start_txt.length > 0)
NAICSlow = parseFloat(search_fields.naics_start_txt.text);
if (search_fields.naics_end_txt.length > 0)
NAICShigh = parseFloat(search_fields.naics_end_txt.text);
}
finally { }
if(search_fields.query_txt.length > 0 && !currNode.childNodes[0].firstChild.nodeValue.toLowerCase().contains(search_fields.query_txt.text.toLowerCase()))
matching = false;
if(matching && search_fields.streetnum_txt.length > 0 && !currNode.childNodes[2].firstChild.nodeValue.toLowerCase().contains(search_fields.streetnum_txt.text.toLowerCase()))
matching = false;
if(matching && search_fields.streetname_txt.length > 0 && !currNode.childNodes[3].firstChild.nodeValue.toLowerCase().contains(search_fields.streetname_txt.text.toLowerCase()))
matching = false;
if(matching && search_fields.description_txt.length > 0 && !currNode.childNodes[11].firstChild.nodeValue.toLowerCase().contains(search_fields.description_txt.text.toLowerCase()))
matching = false;
if(matching && search_fields.geographicMc.text != "Select a Location" && !currNode.childNodes[12].firstChild.nodeValue.toLowerCase().contains(search_fields.geographicMc.text.toLowerCase()))
matching = false;
if(matching && (parseFloat(currNode.childNodes[13].firstChild.nodeValue) < NAICSlow || parseFloat(currNode.childNodes[13].firstChild.nodeValue) > NAICShigh))
matching = false;
if(matching && _global.empRangeValue.toLowerCase() != "all" && !currNode.childNodes[15].firstChild.nodeValue.toLowerCase().contains(_global.empRangeValue.toLowerCase()))
matching = false;
return matching;
}
DisplayNodes = function(nodes, field_txt) {
field_txt.htmlText = "";
var entry;
var separator = "<br>_______________________<br><br>";
for (var i = 0; i < nodes.length; i++) {
entry = "";
entry += "<b>" + nodes[i].childNodes[0].firstChild.nodeValue + "</b>";
entry += " <br>" + "<b>" + "Address: " + "</b>" + nodes[i].childNodes[2].firstChild.nodeValue;
entry += " " + nodes[i].childNodes[3].firstChild.nodeValue;
entry += " " + "Unit " + nodes[i].childNodes[1].firstChild.nodeValue;
entry += "<br>" + "Mississauga, Ontario " + nodes[i].childNodes[4].firstChild.nodeValue;
field_txt.htmlText += entry + separator;
}
}
search_highlight = new TextFormat();
search_highlight.color = 0xFF0000;
search_highlight.italic = true;
HighlightOccurences = function(str, field_txt, format) {
if (!str.length)
return (0);
var start = field_txt.text.indexOf(str);
var end = start + str.length;
while (start != -1){
field_txt.setTextFormat(start, end, search_highlight);
start = field_txt.text.indexOf(str, end);
end = start + str.length;
}
}
search_fields.search_btn.onRelease = function() {
/* if ((search_fields.query_txt.text.length < 3) && (search_fields.streetname_txt.text.length < 3)){
search_fields.query_txt.text = "Please use a search term with 3 or more characters in any or all fields.";
return (0);
} */
var aSearch = search_fields.query_txt.text;
companyWithQuery = SearchXML(posts_xml.firstChild.childNodes);
gotoAndPlay("results");
if (companyWithQuery.length) {
DisplayNodes(companyWithQuery, results.results_txt);
delete companyWithQuery;
delete posts_xml;
} else {
results.results_txt.text = "No results for " + aSearch + ".";
return (0);
}
HighlightOccurences(
aSearch,
results.results_txt,
search_highlight
);
}
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138:





by: tagitPosted on 2007-12-13 at 22:15:43ID: 20470016
Does this help:
e.com/Soft ware/Photo s_Graphics / Web_Graph ics/Macrom edia_Flash /Q_2301929 7.html? cid =236#a2046 8792
http://www.experts-exchang