Selection.addlistener() - MACROMEDIA FLASH MX 2004-ACTIONSCRIPT LANGUAGE Reference

Actionscript language reference
Table of Contents

Advertisement

Selection.addListener()

Availability
Flash Player 6.
Usage
Selection.addListener(newListener:Object) : Void
Parameters
newListener
Returns
None.
Description
Method; registers an object to receive keyboard focus change notifications. When the focus
changes (for example, whenever
with
addListener()
focus change notifications. If the listener
Example
In the following example, you create two input text fields at runtime, setting the borders for each
text field to
true
This object defines for itself an
takes two parameters: a reference to the text field that lost focus, and one to the text field that
gained focus. The function sets the
sets the border property of the text field that gained focus to
this.createTextField("one_txt", 99, 10, 10, 200, 20);
this.createTextField("two_txt", 100, 10, 50, 200, 20);
one_txt.border = true;
one_txt.type = "input";
two_txt.border = true;
two_txt.type = "input";
var focusListener:Object = new Object();
focusListener.onSetFocus = function(oldFocus_txt, newFocus_txt) {
oldFocus_txt.border = false;
newFocus_txt.border = true;
};
Selection.addListener(focusListener);
When you test the SWF file, try using Tab to move between the two text fields. Make sure that
you select Control > Disable Keyboard Shortcuts so you can change focus between the two fields
using Tab.
An object with an
onSetFocus
Selection.setFocus()
have their
onSetFocus
. This code creates a new (generic) ActionScript object named
onSetFocus
border
method.
is invoked), all listening objects registered
method invoked. Multiple objects may listen for
is already registered, no change occurs.
newListener
property, to which it assigns a function. The function
property of the text field that lost focus to
true
focusListener
false
:
Selection.addListener()
.
, and
715

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Flash mx

Table of Contents