FlashExtensions Home | FlashInterface Products Page

Subscriber / Dispatcher Example

Event dispatchers allow you to send instructions to multiple items at the same time. A registered event listener receives notification when an event is dispatched. There are no limits to the number of items than can subscribe to an event.

In this example, we have two SWFs that reside in the web page. We will send an event from one SWF (Dispatcher) and receive the event from the other SWF (Subscriber), which will then display a message in the output window. You may change the SWFs to Flash 8 (AVM1) or Flash 9 (AVM2). Both will communicate and respond to each other the same.

* The Flex icon is used to represent the Flash 9 player. FlashInterface is not limited to Flex and will work within all Flash 9 projects.

Load Flash 8 SWF | Load Flash 9 SWF Load Flash 8 SWF | Load Flash 9 SWF
FlashInterface dispatcher
FlashInterface subscriber

Sample Code for Subscriber


import flx.external.FlashInterface;
FlashInterface.addEventListener("talkToFlash", talkToFlashHandler);

Sample Code for Dispatcher


import flx.external.FlashInterface;
FlashInterface.dispatchEvent({type:"talkToFlash", data:"Hello, world!"});