# What's the matter of my search engine?

**URL:** <https://forum.kirupa.com/t/whats-the-matter-of-my-search-engine/7772>\
**Category:** Uncategorized\
**Created:** [November 7, 2002, 1:22pm UTC](https://forum.kirupa.com/t/whats-the-matter-of-my-search-engine/7772 "2002-11-07T13:22:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![richie](https://avatars.discourse-cdn.com/v4/letter/r/d6d6ee/32.png) [@richie](https://forum.kirupa.com/u/richie)\
**Post date:** [November 7, 2002, 1:22pm UTC](https://forum.kirupa.com/t/whats-the-matter-of-my-search-engine/7772/1 "2002-11-07T13:22:37Z")

</div>

hi there, i was doing a little search engine in flash mx, but it have some problems.

i load the content of a text file, there is a lot of names, and some data too, and i have to search a name for example, ok, when i first search a name, ok, i use the Selection.setSelection to highlight the name or whatever i search, but after the first time i search, i don’t search anymore!!! what’s the matter of this thing?

well let me show you guys the script:

on(release){  
result = \_root.textos.htmlText.indexOf(texto\_pesquisa.text);  
if(texto\_pesquisa.text != “” && result \>= 0){  
Selection.setFocus(\_root.textos);  
Selection.setSelection(result, result + texto\_pesquisa.text.length);  
}else{  
texto\_pesquisa.text = “Nome inexistente…”;  
}  
}

this script is attached to a button, within the “pesquisa” MC, wich is in the \_root of the movie.

does anyone see what’s wrong?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 7, 2002, 4:04pm UTC](https://forum.kirupa.com/t/whats-the-matter-of-my-search-engine/7772/2 "2002-11-07T16:04:56Z")

</div>

indexOf returns the first one that matches, is it possible it just keeps finding the same one??

If so then you need to create a substring after you found the first one and do an indexOf on that.

Hope this helps

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 7, 2002, 5:22pm UTC](https://forum.kirupa.com/t/whats-the-matter-of-my-search-engine/7772/3 "2002-11-07T17:22:54Z")

</div>

ok, i’ll try something like that, but, i don’t see why is wrong, all the search dependes on what is on the text field:

result = \_root.textos.htmlText.indexOf(texto\_pesquisa.text);

every time i release the button, it takes the value and then do the search. And why when i first search and return the correct result, why the word didn’t highlight? (Selection.setSelection(result, result + texto\_pesquisa.text.length)😉 ???

thanks for the help, i tought doing diferent but not get there it…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 8, 2002, 10:13am UTC](https://forum.kirupa.com/t/whats-the-matter-of-my-search-engine/7772/4 "2002-11-08T10:13:43Z")

</div>

YEEESS! Got it, this is the correct script that does the search:

on(release){  
result = \_root.textos.text.indexOf(texto\_pesquisa.text);  
if(texto\_pesquisa.text != “” && result \>= 0){  
Selection.setFocus(\_root.textos);  
Selection.setSelection(result, result + texto\_pesquisa.text.length);  
}else{  
texto\_pesquisa.text = “Nome inexistente…”;  
}  
}

didn’t need the substr at all.
