This post is already quite old. As such its contents may be outdated, obsolete or outright wrong. Please handle its content with care and question any recommendations it might give you.

Also, if you find any dead links please let me know, I'll try to replace them with links to an archived version .

LocalConnectionSync v0.1 released

For a current project that is heavily based on multiple swf’s communicating via LocalConnection I realized that how LocalConnection works in Flash is far from intuitive. What I needed was a way to connect to a bunch of swfs, manage these connections and react to status changes. Some kind of solution to manage this was needed.

Of course the first thing I did was doing some research to see if someone had already coded such a thing. Surprisingly what I found wasn’t much:

First I found asLocalConnect. It looked quite nice with a lot of features and good documentation. But when I had a look at the source code I was a bit disappointed. The source code wasn’t too well documented and the coding style putting everything in one class with multiple generic objects as data storage didn’t really feel right. Finally a lot of features like abstracting the security settings into levels and internally trying to fix name collisions with so called “channels” might be nice for some people, but for me it was unnecessary bloat.

Next I stumbled upon the LocalConnectionManager being a part of the DevelopmentArc Core. This also made me move on as I wanted a lightweight solution without any unnecessary dependencies.

Finally I found flashlcs. The main focus of this project obviously is “high speed” data transfer (coping with the 40kb limit of LocalConnection) and the possibility for two way communication (method return) which again wasn’t really what I was looking for.
So what else then? Right, do it yourself.

LocalConnectionSync

LocalConnectionSync is a lightweight way to connect various swfs and receive Events if the connection status changes. Here is just a short feature list:

  • Define a set of clients to connect to
  • Status Events (established, timed out, lost)
  • Broadcast to all clients
  • Send to one specific client
  • Define a handler object that handles all those method calls

Download LocalConnectionSync Source & Examples

This is the first release so if you find any bugs or have any ideas for improvement feel free to leave a comment.

Examples

This was built with flash, which won’t run any more on most modern browsers which is why I have removed the inline examples. If you’d like to do some web archeology get the download above.

Connect and lose Connection

Those two swfs try to connect which should work out fine. If you click “remove bottom to test Events” below the “bottom” swf is removed which should soon make the “top” swf notice that it has lost connection to “bottom”.

Timeout

This swf tries to connect to a non existent swf which of course will end with a time out.