MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT Reference Manual page 86

Actionscript reference guide
Hide thumbs Also See for FLASH MX 2004 - ACTIONSCRIPT:
Table of Contents

Advertisement

To create a simple focus manager with event listeners:
Using the Text tool, create a text field on the Stage.
1
Select the text field and, in the Property inspector, select Input from the Text Type pop-up
2
menu, and select the Show Border Around Text option.
Create another input text field below the first one.
3
Make sure the Show Border Around Text option is not selected for this text field. Continue to
create input text fields if desired.
Select Frame 1 in the Timeline and open the Actions panel (Window > Development
4
Panels > Actions).
To create an object that listens for focus notification from the Selection class, enter the following
5
code in the Actions panel:
var focusListener = new Object();
focusListener.onSetFocus = function(oldFocus_txt, newFocus_txt) {
oldFocus_txt.border = false;
newFocus_txt.border = true;
}
This code creates a new (generic) ActionScript object named
defines for itself an
two parameters: a reference to the text field that lost focus, and one to the text field that gained
focus. The function sets the
the
property of the text field that gained focus to
border
To register the
6
following code to the Actions panel:
Selection.addListener(focusListener);
Test the movie (Control > Test Movie), click in the first text field, and press Tab to switch focus
7
between fields.
To unregister a listener object from receiving events, you call the
the broadcaster object, passing it the name of the listener object.
broadcastObject.removeListener(listenerObject);
Event listeners are available to objects of the following ActionScript classes: Key, Mouse,
MovieClipLoader, Selection, TextField, and Stage. For a list of event listeners available to each
class, see these class entries in
86
Chapter 4: Handling Events
property, to which it assigns a function. The function takes
onSetFocus
property of the text field that lost focus to
border
object to receive events from the Selection object, add the
focusListener
Chapter 12, "ActionScript Dictionary," on page
. This object
focusListener
false
.
true
removeListener()
205.
, and sets
method of

Advertisement

Table of Contents
loading
Need help?

Need help?

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

Subscribe to Our Youtube Channel

Table of Contents