User Guide

Selection.onSetFocus 721
Selection.onSetFocus
Availability
Flash Player 6.
Usage
someListener.onSetFocus = function( [ oldFocus:Object [, newFocus:Object ] ]){
// statements;
}
Parameters
oldfocus
The object losing focus. This parameter is optional.
newfocus The object receiving focus. This parameter is optional.
Description
Listener; notified when the input focus changes. To use this listener, you must create a listener
object. You can then define a function for this listener and use Selection.addListener() to register
the listener with the Selection object, as in the following code:
var someListener:Object = new Object();
someListener.onSetFocus = function () {
// statements
}
Selection.addListener(someListener);
Listeners enable different pieces of code to cooperate because multiple listeners can receive
notification about a single event.
Example
The following example demonstrates how to determine when input focus changes in a SWF file
between several dynamically created text fields. Enter the following ActionScript into a FLA or AS
file and then test the document:
this.createTextField("one_txt", 1, 0, 0, 100, 22);
this.createTextField("two_txt", 2, 0, 25, 100, 22);
this.createTextField("three_txt", 3, 0, 50, 100, 22);
this.createTextField("four_txt", 4, 0, 75, 100, 22);
for (var i in this) {
if (this[i] instanceof TextField) {
this[i].border = true;
this[i].type = "input";
}
}
this.createTextField("status_txt", this.getNextHighestDepth(), 200, 10, 300,
100);
status_txt.html = true;
status_txt.multiline = true;
var someListener:Object = new Object();
someListener.onSetFocus = function(oldFocus, newFocus) {