I needed the same thing, to select the contents of a textfield when it receives focus.
I tried:
A) Simply selecting after a FocusEvent. This doesn't seem to work (my guess is that FocusEvents are fired before the mouse click is being processed, which in turn will undo the selection).
B) Selecting on every mouse click. This works, but this is very annoying for a user who wants to select only a part of the text later, since this attempt will always result in -all- the content being selected.
The following workaround seems to work though:
myTextField.addEventListener(MouseEvent.CLICK, selectAllOnce);
function selectAllOnce(e:MouseEvent) {
e.target.removeEventListener(MouseEvent.CLICK, selectAllOnce);
e.target.addEventListener(FocusEvent.FOCUS_OUT, addSelectListener);
selectAll(e);
}
function addSelectListener(e:FocusEvent) {
e.target.addEventListener(MouseEvent.CLICK, selectAllOnce);
e.target.removeEventListener(FocusEvent.FOCUS_OUT, addSelectListener);
}
function selectAll(e:Event) {
e.target.setSelection(0, e.target.getLineLength(0));
}
Hope that helps. I personally think it would be most logical if adobe simply added an option for this for the TextField object.