# LocalConnection object

#### Availability

Flash Player 6.

Note: The LocalConnection object is available only in the expert mode of the Actions panel.

The LocalConnection object lets you develop Flash movies (SWFs) that can send instructions to each other without the use of fscommand or JavaScript. LocalConnection objects can communicate only between movies that are running on the same client machine, but they can be running in two different applications—for example, a Flash movie running in a browser and a Flash movie running in a projector. You can use LocalConnection objects to send and receive data within a single movie, but this is not a standard implementation; all the examples in this section illustrate communication between different movies.

The primary methods used to send and receive data are `LocalConnection.send()` and`` `LocalConnection.connect()`. At its most basic, your code will implement the following commands; note that both the `LocalConnection.send()` and `LocalConnection.connect()` commands specify the same connection name, `lc_name`:

    // Code in the receiving movie
    receiving_lc = new LocalConnection();
    receiving_lc.methodToExecute = function(param1, param2)
    {
    	// Code to be executed
    }
    receiving_lc.connect("lc_name");

    // Code in the sending movie
    sending_lc = new LocalConnection();
    sending_lc.send("lc_name", "methodToExecute", dataItem1, dataItem2)

The simplest way to use the LocalConnection object is to allow communication only between LocalConnection objects located in the same domain, since you won't have to address issues related to security. However, if you need to allow communication between domains, you have a number of ways to implement security measures. For more information, see the discussion of the `connectionName` parameter in `LocalConnection.send()`, and also the `LocalConnection.allowDomain` and `LocalConnection.domain()` entries.

## Method summary for the LocalConnection object

Method | Description
--- | ---
`LocalConnection.close()` | Closes (disconnects) the LocalConnection object.
`LocalConnection.connect()` | Prepares the LocalConnection object to receive commands from a `LocalConnection.send()` command.
`LocalConnection.domain()` | Returns a string representing the subdomain of the location of the current movie.
`LocalConnection.send()` | Invokes a method on a specified LocalConnection object.

## Event handler summary for the LocalConnection object

Event handler | Description
--- | ---
`LocalConnection.allowDomain` | Invoked whenever the current (receiving) LocalConnection object receives a request to invoke a method from a sending LocalConnection object.
`LocalConnection.onStatus` | Invoked after a sending LocalConnection object tries to send a command to a receiving LocalConnection object.

## Constructor for the LocalConnection object

#### Availability

Flash Player 6.

#### Usage

    new LocalConnection()

#### Parameters

None.

#### Returns

A reference to a LocalConnection object.

#### Description

Constructor; creates a LocalConnection object.

#### Example

The following example shows how a receiving and sending movie create LocalConnnection objects. Note that the two movies can use the same name or different names for their respective LocalConnection objects. In this example, they use the same name—`my_lc`.

    // Code in the receiving movie
    my_lc = new LocalConnection();
    my_lc.someMethod = function()
    {
    	// Your code here
    }
    my_lc.connect("connectionName");

    // Code in the sending movie
    my_lc = new LocalConnection();
    my_lc.send("connectionName", "someMethod");

#### See also

`LocalConnection.connect()`, `LocalConnection.send()`