Search engine for text file

i hv a bulk of text pages in my flash file. i want a search box that could identify specific keywords in those paras when asked for.

is that possible?

Speaking from Flash5

Declare you text file as a string object.

Use the methods String.indexOf() and StringLastIndexOf() to determine the starting character position of your index string within the primary string (String.LastIndex() of is used to determine if there are multiple instances of the index string within the primary string)

Use Selection.setFocus() to focus your text box.

Use Selection.setSelection() to highligh the index string.

Depending on the size of your text files you may want to brak them into manageable chunks (say 1000 characters) if you find that string.indexOf() is taking noticeably long to execute.

If you have multiple instances of the same index string within the primary string you can use String.substr() and/or String.substring to determine their position by slicing the primary string after the first occurrence and searching again using String.indexOf()/ String.lastIndexOf()

jsk…thanx a lot 4 replying…

i was wondering if u could supply an example of the script here. for ur info, my text are academic in nature (for eg. legal), hence they are long and extensive. how could i break them into manageable chunks?

appreciate ur help…

This example defines a string called sourceText and then highlights the string indexText where it occurs in sourceText.

Draw a dynamic text box on the main timeline with the variable name sourceText

On a separate layer place this code in frame 1

sourceText = “The cat is on the mat.”;
indexText = “cat”;

and this code in frame 2

Selection.setFocus(“sourceText”);
Selection.setSelection(sourceText.indexOf(indexText),sourceText.indexOf(indexText)+indexText.length);
stop ();