Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

search not working

Status
Not open for further replies.

cathiec

Programmer
Oct 21, 2003
139
IE
there are two text boxes in a frame in my movie, one called d and one called s. a button called search_btn has also been created. the pepose is to enter text into the textbox s and then click the button search_btn to search for the text in the textbox d. i am using the actionscript below but nothing happens when the button is clicked.

onClipEvent (load) {
stop();
/* d - is the instance id of the text field to be searched
s - is the instance id of the text (input) field to be searched for
search_btn - is the instance id of the search button placed in the frame with
the text fields
*/

var begin:Number; // beginning index of search string
var len:Number; // length of search string

TF = new TextFormat(); // text format for italic
TF.italic = true;

btnListener = new Object();
btnListener.click = function () {
begin = _root.d.text.indexOf(_root.s.text); // find the beginning of the string
len = _root.s.text.length; // find the length of the search string
d.setTextFormat(begin, begin + len, TF); // change the format of the located text
}

search_btn.addEventListener ("click", btnListener); // listener for search button


}
 
I can't say with certainty that what you're doing is wrong or won't work, but why not just add event handlers to the button instance rather than creating listener objects?

I'd try that and see if it works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top