broadcastMessage (AsBroadcaster.broadcastMessage method)

public broadcastMessage(eventName:String) : Void

Sends an event message to each object in the list of listeners. When the message is received by the listening object, Flash Player attempts to invoke a function of the same name on the listening object. Suppose that your object broadcasts an event message like this:

obj.broadcastMessage("onAlert");

When this message is received, Flash Player invokes a method named onAlert() on the receiving listener object.

Note: You can pass arguments to your listener functions by including additional arguments to the broadcastMessage() method. Any arguments that appear after the eventName parameter are received as arguments by the listener method.

You can call this method only from an object that was initialized by using the AsBroadcaster.initialize() method.

Availability: ActionScript 1.0; Flash Player 6

Parameters

eventName:String - The name of the event to broadcast. The name of any listener methods must match this parameter in order to receive the broadcast event. You can pass arguments to the listener methods by including additional arguments after eventName.

Example

The following example is an excerpt from the first full example provided in the entry for the AsBroadcaster.initialize() method:

someObject.broadcastMessage("someEvent"); // Broadcast the "someEvent" message. 

The following example is an excerpt from the second full example provided in the entry for the AsBroadcaster.initialize() method. It shows how to send arguments to listener methods.

someObject.broadcastMessage("someEvent", 3, "arbitrary string");

See also

initialize (AsBroadcaster.initialize method), removeListener (AsBroadcaster.removeListener method)