03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The following example is an excerpt from the second full example provided in the entry for<br />

the AsBroadcaster.initialize() method. It shows how to send arguments to listener<br />

methods.<br />

someObject.broadcastMessage("someEvent", 3, "arbitrary string");<br />

See also<br />

initialize (AsBroadcaster.initialize method), removeListener<br />

(AsBroadcaster.removeListener method)<br />

initialize (AsBroadcaster.initialize method)<br />

public static initialize(obj:Object) : Void<br />

Adds event notification <strong>and</strong> listener management functionality to a given object. This is a<br />

static method; it must be called by using the AsBroadcaster class (where someObject is the<br />

name of the object to be initialized as an event broadcaster):<br />

AsBroadcaster.initialize(someObject);<br />

Note: A common mistake is to capitalize the second letter of AsBroadcaster. When calling the<br />

AsBroadcaster.initialize() method, ensure that the second letter is lowercase. Any<br />

misspelling of AsBroadcaster will fail silently.<br />

This method adds the _listeners property along with the following three methods to the<br />

object specified by the obj parameter:<br />

■ obj.addListener()<br />

■ obj.removeListener()<br />

■ obj.broadcastMessage()<br />

Availability: <strong>ActionScript</strong> 1.0; Flash Player 6<br />

Parameters<br />

obj:Object - An object to serve as a broadcasting object.<br />

Example<br />

The following example creates a generic object, someObject, <strong>and</strong> turns it into an event<br />

broadcaster. The output should be the strings shown in the two trace() statements:<br />

var someObject:Object = new Object(); // Creates broadcast object.<br />

var myListener1:Object = new Object(); // Creates listener object.<br />

var myListener2:Object = new Object(); // Creates listener object.<br />

AsBroadcaster 275

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!