Chapter 44. Local Connections between Flash Applications



Using the LocalConnection class, you can enable multiple Flash applications running on the same computer to communicate with each other. This is interprocess communication (IPC) for the Flash platform. I covered client-server communication in Chapter 28, "Communicating with Remote Services": here I introduce client-client communication. Local connections work without a network connection of any kind, directly between ActionScript running in both applications.

Local Connections and Their Uses

Local connections enable communication between one or more Flash platform applications on the same computer without additional tooling. Just like most of the client-server techniques used in Chapter 28, by "communication" I specifically mean "method invocation." After you open a local connection from a sending application A to a receiving application B, application A can call methods, optionally passing arguments, to application B. This connection is one way in that A can only call methods on B. However, you can program a simple handshaking protocol that makes B establish a parallel connection back to A so that one connection exists for each direction, simulating bidirectional communication. Furthermore, the one-directional communication extends to return values: A can call methods on B, but any return values from B methods are lost; they are not sent back to A. The method invocations are asynchronous, ...

Get ActionScript 3.0 Bible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.