Search Engine! Urgent Help Needed!

  • ipdstudent
  • Novice
  • Novice
  • ipdstudent
  • Posts: 16
  • Loc: London

Post 3+ Months Ago

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:


Quote:
<?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:

Quote:
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]
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

you need to modify the DisplayNodes functions and add a new movieclip instead of this part of code:
Code: [ Select ]
if (nodes[i].attributes.url.length){
entry += "<a href='" + nodes[i].attributes.url;
entry += "'><font color='#0000FF'>Read more...</font></a>";
}
  1. if (nodes[i].attributes.url.length){
  2. entry += "<a href='" + nodes[i].attributes.url;
  3. entry += "'><font color='#0000FF'>Read more...</font></a>";
  4. }

you need to attach a movieclip with a textfield : Read more ...,
and in that movieclip you need to have a onPress method which redirect you to the desired frame.
Code: [ Select ]
this.attachMovieClip("TextRead", 100);
TextRead._x = results_txt._x + 10;
TextRead._x = results_txt._y + 20;
TextRead.display_text.text = "Read more...";
  1. this.attachMovieClip("TextRead", 100);
  2. TextRead._x = results_txt._x + 10;
  3. TextRead._x = results_txt._y + 20;
  4. TextRead.display_text.text = "Read more...";

i.e.:
code in the first frame of the movieclip with the text:
Code: [ Select ]
this.onPress = function() {
    gotoAndPlay("frameResults");
}
  1. this.onPress = function() {
  2.     gotoAndPlay("frameResults");
  3. }
  • ipdstudent
  • Novice
  • Novice
  • ipdstudent
  • Posts: 16
  • Loc: London

Post 3+ Months Ago

Wow, thanks very much IceCold...over the next few days im going to try this out and if this works i will let u knw..thanx so so so so much for helping
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

if you do it correctly then it will work.
  • ipdstudent
  • Novice
  • Novice
  • ipdstudent
  • Posts: 16
  • Loc: London

Post 3+ Months Ago

Hey IceCold, i am having some problems with the search engine which is inevitable because im quite useless at action script :( i hope u dnt mind, but i have added u on msn cuz im quite stuck with this!
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

i rarely use msn. Mostly yahoo messenger
  • ipdstudent
  • Novice
  • Novice
  • ipdstudent
  • Posts: 16
  • Loc: London

Post 3+ Months Ago

oh rite...would it be alright if i speak to u on yahoo?
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

sure, just add me
  • ipdstudent
  • Novice
  • Novice
  • ipdstudent
  • Posts: 16
  • Loc: London

Post 3+ Months Ago

sorry whats ur yahoo? lol its not on ur profile.

Post Information

  • Total Posts in this topic: 9 posts
  • Users browsing this forum: No registered users and 14 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.