I am trying to create a search engine in flash 8 and using an xml document to hold the search results. What i want it to do is for the user to enter something into the search field...the results come up and for them to click on a result and it taking them to a new frame or scene! i found a search engine tutorial online which does this, but it the results take u to an external URL not a new frame, and i cant figure out how to alter it to change this! any ideas from anyone? The XML document is as follows:
<?xml version="1.0" ?>
<bestof url="http://www.kirupaforum.com/forums/forumdisplay.php?f=12">
<post url="http://www.kirupaforum.com/forums/showthread.php?t=43216">
<title>xml menu DONE </title>
</post>
<post url="http://www.kirupaforum.com/forums/showthread.php?t=51430">
<title>Howd he do this? Resizing slideshow</title>
</post>
It just goes down a list like this of different values...and the action script is:
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;
}
SearchXML = function(nodes, query, useChildElements){
var results = [];
for (var i=0; i<nodes.length; i++){
for (var j=0; j<nodes[i].childNodes.length; j++){
currNode = nodes[i].childNodes[j];
if (useChildElements.contains(currNode.nodeName)){
if (currNode.firstChild.nodeValue.contains(query)){
results.push(nodes[i]);
break;
}
}
}
}
return results;
}
ElementsToSearch = function(){
var childElementsToSearch = [];
if (search_fields.title_check.checked){
childElementsToSearch.push("title");
}
return childElementsToSearch;
}
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>"+ nodes[i].childNodes[2].firstChild.nodeValue;
if (nodes[i].attributes.url.length){
entry += "<a href='" + nodes[i].attributes.url;
entry += "'><font color='#0000FF'>Read more...</font></a>";
}
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;
}
}
var posts_xml = new XML();
posts_xml.ignoreWhite = true;
posts_xml.onLoad = function(success){
if (success){
search_fields._visible = true;
}else results_txt.text = "Error loading XML";
}
search_fields._visible = false;
posts_xml.load("bestofposts.xml");
search_fields.title_check.title_txt.text = "Title";
search_fields.search_btn.onRelease = function(){
if (search_fields.query_txt.text.length < 3){
results_txt.text = "Please use a search term with 3 or more characters.";
return (0);
}
var searchElements = ElementsToSearch();
var nodesWithQuery = SearchXML(
posts_xml.firstChild.childNodes,
search_fields.query_txt.text,
searchElements
);
if (nodesWithQuery.length){
DisplayNodes(
nodesWithQuery,
results_txt
);
}else{
results_txt.text = "No results for "+search_fields.query_txt.text+".";
return (0);
}
HighlightOccurences(
search_fields.query_txt.text,
results_txt,
search_highlight
);
}
What do i need to do!!??? Any help is greatly appreciated..[/quote]