Tutorials, extensions, and source files for ActionScript, Flash, and other Adobe products.

 

senocular.com ActionScript Library

selectAll.as

Name: selectAll() - textfield select all text with optional delay
Author: senocular: www.senocular.com
Date: 1899-12-31T00:34:44.800
Documentation:
TextField SELECTALL: Selects all text in a textField.

TextField.selectAll(delay);

Arguments:
- delay: (optional) time in milliseconds to delay the selection.  This may be desirable in
case you use a mouseUp event like in the example but fear the user might click within the
textfield thereby altering the selection.  Delaying the selectAll will prevent that click
having an affect on the final selection.

Returns:
- nothing

Example:
// selects hilite_txt textfield on mouse down
this.onMouseDown = function(){
	hilite_txt.selectAll();
}

1
2
3
4
5
6
7
8
9
10
11
12
13
TextField.prototype.selectAll = function(delay){
	if (delay){
		var tf = this;
		var ID = setInterval(function(){
			Selection.setFocus(tf);
			Selection.setSelection(0,tf.length);
			clearInterval(ID);
		}, delay);
	}else{
		Selection.setFocus(this);
		Selection.setSelection(0,this.length);
	}				  
}