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.

Example<br />

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

AsBroadcaster.initialize() method.<br />

someObject.addListener(myListener1); // Register myListener1 as listener.<br />

someObject.addListener(myListener2); // Register myListener2 as listener.<br />

See also<br />

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

(AsBroadcaster.removeListener method)<br />

broadcastMessage<br />

(AsBroadcaster.broadcastMessage method)<br />

public broadcastMessage(eventName:String) : Void<br />

Sends an event message to each object in the list of listeners. When the message is received by<br />

the listening object, Flash Player attempts to invoke a function of the same name on the<br />

listening object. Suppose that your object broadcasts an event message like this:<br />

obj.broadcastMessage("onAlert");<br />

When this message is received, Flash Player invokes a method named onAlert() on the<br />

receiving listener object.<br />

Note: You can pass arguments to your listener functions by including additional arguments to<br />

the broadcastMessage() method. Any arguments that appear after the eventName<br />

parameter are received as arguments by the listener method.<br />

You can call this method only from an object that was initialized by using the<br />

AsBroadcaster.initialize() method.<br />

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

Parameters<br />

eventName:String - The name of the event to broadcast. The name of any listener methods<br />

must match this parameter in order to receive the broadcast event. You can pass arguments to<br />

the listener methods by including additional arguments after eventName.<br />

Example<br />

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

AsBroadcaster.initialize() method:<br />

someObject.broadcastMessage("someEvent"); // Broadcast the "someEvent"<br />

message.<br />

274 <strong>ActionScript</strong> classes

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

Saved successfully!

Ooh no, something went wrong!