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 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
This is the first release so if you find any bugs or have any ideas for improvement feel free to leave a comment.
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”.
This swf tries to connect to a non existent swf which of course will end with a time out.