Chapter 37. Using Local Connections to Communicate Between Flash Applications

Introduction

In this chapter

  • Creating local domain communication between Flash applications

  • Creating communication between Flash applications across domains

The flash.net.LocalConnection class allows for any Flash application in any player to communicate with any other Flash application in any other player on the same computer without needing any complicated JavaScript or other workarounds. All that is required is that the applications run on the same computer and that one is set up to broadcast messages and the other is set up to listen for messages. As an example of how you might use LocalConnection, consider that an application deployed on the Web could consist of several SWF files that need to work in conjunction with one another. With LocalConnection, the SWFs can communicate. There are many possibilities with LocalConnection. In this chapter, you learn how to work with the LocalConnection class.

Creating a Sending Application

There are essentially two types of applications related to LocalConnection communication. The first of these is the sending application. Sending can be accomplished in as few as two steps. The first step is obviously to create a LocalConnection object. The LocalConnection constructor requires no parameters, so you can create an object like this:

var sender:LocalConnection = new LocalConnection();

After you have created the object, you need only to call the send() method in order ...

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.