Hey guys,

I'm currently working on a flash/xml project that is pulling information from the xml file and displaying the names and information of the company's that have been returned from the search. I would like the search to be able to show up in pages. For example every search would show its results in a group of 10, and allow you to use <<previous and next>> buttons to browse through the search pages. I have a basic idea of how this would work, but am unsure as to how I would go about coding it into my document. Any help you guys could provide would be greatly appreciated. Below is the main code from my document.

Thanks


Code:
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[3].firstChild.nodeValue.toLowerCase().contains(search_fields.streetnum_txt.text.toLowerCase()))
                matching = false;
        if(matching && search_fields.streetname_txt.length > 0 && !currNode.childNodes[4].firstChild.nodeValue.toLowerCase().contains(search_fields.streetname_txt.text.toLowerCase()))
                matching = false;
        if(matching && search_fields.description_txt.length > 0 && !currNode.childNodes[15].firstChild.nodeValue.toLowerCase().contains(search_fields.description_txt.text.toLowerCase()))
                matching = false;
        if(matching && search_fields.geographicMc.text != "Select a Location" && !currNode.childNodes[16].firstChild.nodeValue.toLowerCase().contains(search_fields.geographicMc.text.toLowerCase()))
                matching = false;
        if(matching && (parseFloat(currNode.childNodes[17].firstChild.nodeValue) < NAICSlow || parseFloat(currNode.childNodes[17].firstChild.nodeValue) > NAICShigh))
                matching = false;
        if(matching && _global.empRangeValue.toLowerCase() != "all" && !currNode.childNodes[19].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[5].firstChild.nodeValue;
 
                entry += " " + "Unit " + nodes[i].childNodes[2].firstChild.nodeValue;
                entry += "<br>" + nodes[i].childNodes[7].firstChild.nodeValue + ", Ontario";
                entry += "<br>" + "<b>" + "Phone: " + "</b>" + nodes[i].childNodes[11].firstChild.nodeValue;
                entry += "<br>" + "<b>"+ "Contact Name: "+"</b>" + nodes[i].childNodes[13].firstChild.nodeValue;
                entry += "<br>" + "<b>" + "Title/Position: " +"</b>" + nodes[i].childNodes[14].firstChild.nodeValue;
                entry += "<br>" + "<b>"+ "Company Size: "+ "</b>" + nodes[i].childNodes[19].firstChild.nodeValue;
                entry += "<br>" + "<b>"+ "Description: " + "</b>"+ nodes[i].childNodes[15].firstChild.nodeValue;
                entry += "<br>" + "<b>"+ "Geographical District: "+"</b>"+ nodes[i].childNodes[16].firstChild.nodeValue;
                entry += "<br>" + "<b>" + "NAICS: " + "</b>" + nodes[i].childNodes[17].firstChild.nodeValue;
                entry += "<br>" + "<b>"+ "Status: "+"</b>" + nodes[i].childNodes[18].firstChild.nodeValue;
                entry += "<br>" + "<b>"+ "Web Address: "+"</b>"
                if(nodes[i].childNodes[12].firstChild.nodeValue.toUpperCase() == "N/A")
                        entry += "N/A";
                else
                        entry += "<a href='http://" + nodes[i].childNodes[12].firstChild.nodeValue + "'>" + nodes[i].childNodes[12].firstChild.nodeValue + "</a>";
                entry += "<br>" + "<br>";
                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
        );
}