Flash / Flex / ActionScript/TextField/selection — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 09:19, 26 мая 2010
Selecting Text with ActionScript
package {
import flash.display.Sprite;
import flash.text.TextField;
public class Main extends Sprite {
public function Main( ) {
var field:TextField = new TextField( );
stage.focus = field; // Set the focus to the text field
field.text = "this is example text"; // Set the text value
field.setSelection(0, 4); // Highlight the word "this"
addChild(field);
}
}
}
Use the read-only selectionBeginIndex and selectionEndIndex properties to retrieve the indices of the selected character range.
package {
import flash.display.Sprite;
import flash.text.TextField;
public class Main extends Sprite {
public function Main( ) {
var field:TextField = new TextField( );
stage.focus = field; // Set the focus to the text field
field.text = "this is example text"; // Set the text value
field.setSelection(0, 4); // Highlight the word "this"
addChild(field);
}
}
}