Wrox Programmer Forums
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Flash (all versions) section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 16th, 2007, 02:34 PM
Authorized User
 
Join Date: Feb 2007
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Default setSelected problem

I have the following bit of code that searches a movie clip frame for an inputted text string. I works the first time the button is pressed...but doesnt work again...any ideas on how to clear the vars so it will work a second and third attempt?
Code:
on (release) {
//search testing+
import mx.controls.Alert;
my_snap.setSelected(index1, textSel, false);
var inputterString:String = _root.inputter;
var inputLength:Number = inputterString.length;
var my_mc:MovieClip = _root.viewport;
var my_snap:TextSnapshot = my_mc.getTextSnapshot();
var index1:Number = my_snap.findText(0, inputterString, false);
var textSel:Number = index1 + inputLength;
trace(index1);
trace(inputLength);
trace(textSel);
/////find selection
if (index1 != -1){
my_snap.setSelectColor(0xFF0000); 
my_snap.setSelected(index1, textSel, true); 
var theText:String = my_snap.getSelectedText(false);
}
if (index1 == -1){
    mx.controls.Alert.show("Nothing found Matching your Search Criteria");
}

//end find
trace(theText); // Text

}









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.