Input Text Field Search Box
I am new to actionscript and trying to figure out how to create a search box. I've been experimenting by placing a dynamic classic text field on the stage with some text already in it. I've also placed an input text field on the stage to use as a search box.
I try to type in a single word to search for in the search box but it won't return any index value. I only get an index returned if the input text exactly matches the entire string in the dynamic text field. How do I get the search box to return the index of only an input substring?
Here's my code:
import flash.text.*;
import flash.events.*;
var index:int = -1;
submit_btn.addEventListener(MouseEvent.CLICK, textSearch);
function searchText():void {
trace("Button Clicked");
while ((index = dynamicText.text.indexOf(inputText.text, index + 1)) != -1)
{
trace(inputText.text + " at index " + index);
}
}
function textSearch(e:MouseEvent):void {
searchText();
}