Advertisement |
Selecting text
The flash.text.TextField.selectable property
is true by default, and you can programmatically select text using
the setSelection() method.
For example, you can set
specific text within a text field to be selected when the user clicks the text
field:
var myTextField:TextField = new
TextField();
myTextField.text = "No
matter where you click on this text field the TEXT IN ALL CAPS is
selected.";
myTextField.autoSize =
TextFieldAutoSize.LEFT;
addChild(myTextField);
addEventListener(MouseEvent.CLICK,
selectText);
function
selectText(event:MouseEvent):void
{
myTextField.setSelection(49, 65);
}
Selecting text
var myTextField:TextField = new
TextField();
myTextField.text = "No
matter where you click on this text field the TEXT IN ALL CAPS is
selected.";
myTextField.autoSize =
TextFieldAutoSize.LEFT;
addChild(myTextField);
addEventListener(MouseEvent.CLICK,
selectText);
function
selectText(event:MouseEvent):void
{
myTextField.setSelection(49, 65);
}
0 comments: