270
ActionScript classes
_listeners (AsBroadcaster._listeners property)
A list of references to all registered listener objects. This property is intended for internal use,
and is not intended for direct manipulation. Objects are added to and removed from this
array by calls to the
addListener()
and
removelistener()
methods.
You can call this property only from an object that was initialized by using the
AsBroadcaster.initialize()
method.
Availability:
ActionScript 1.0; Flash Player 6
Example
The following example shows how to use the
length
property to ascertain the number of
listener objects currently registered to an event broadcaster. The following code works if it is
added to the first full example in the Examples section of the
AsBroadcaster.initialize()
entry:
trace(someObject._listeners.length); // Output: 2
For advanced users, the following example shows how to use the
_listeners
property to list
all of the listeners registered with an event broadcaster, along with all of the properties of each
listener object. The following example creates two different listener methods for the first
listener object.
var someObject:Object = new Object(); // create broadcast object
var myListener1:Object = new Object(); // create listener object
var myListener2:Object = new Object(); // create listener object
myListener1.someEvent = function() { // create listener method
trace("myListener1 received someEvent");
}
myListener1.anotherEvent = function() { // create another listener method
trace("myListener1 received anotherEvent");
}
myListener2.someEvent = function() { // create listener method
trace("myListener2 received someEvent");
}
AsBroadcaster.initialize(someObject); // make someObject an event
broadcaster
someObject.addListener(myListener1); // register myListener1 as listener
someObject.addListener(myListener2); // register myListener2 as listener
var numListeners:Number = someObject._listeners.length; // get number of
registered listeners
Содержание FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
Страница 1: ...ActionScript 2 0 Language Reference ...
Страница 1352: ...1352 ActionScript classes ...