Bardbarian on Steam - coming s…
A Meandering Path to an Evolvi…Quick as a FlashThings Every ActionScript Deve…Making Money with Adobe AIRUsing Flash for 3D Game MMO UIUtilizing Flash for Game UI De…Why I (Still) Love FlashMy Favourite Things
Posted on July 30, 2007 by Grant Skinner
A few months ago I built a class that makes establishing two way communication between SWFs via LocalConnection much easier. This is useful for talking between different SWFs embedded on the same HTML page, but especially for communicating between an ActionScript 3 application SWF, and loaded ActionScript 2 content SWFs.
It’s fairly easy to use, just create a SWFBridge instance inside each SWF with a shared id:
The SWFBridge system will automatically negotiate a two way connection between the two instances. The nice thing is, you don’t need to wait for your content to be loaded to instantiate your bridge âÂ it will set itself up as a host, and wait for another bridge instance to connect to it. Now you simply call “send” on either SWFBridge instance to call a method on the clientObj of the other instance.
When you’re ready to unload your SWF, it’s usually a good idea to close the connection to free up the LocalConnection name.
You can also check the status of your connection, and receive an event when the connection is established.
Here’s a very simple (and ugly) demo of the system in action. It shows an AS3 SWF (top) communicating with a loaded AS2 SWF (bottom) through SWFBridge.
Follow @gskinner on Twitter for more news and views on interactive media.