EasyManua.ls Logo

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT - Localconnection Class

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT
816 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
434 Chapter 12: ActionScript Dictionary
LocalConnection class
Availability
Flash Player 6.
Description
The LocalConnection class lets you develop SWF files that can send instructions to each other
without the use of
fscommand() or JavaScript. LocalConnection objects can communicate only
between SWF files that are running on the same client machine, but they can be running in two
different applications—for example, a SWF file running in a browser and a SWF file running in a
projector. You can use LocalConnection objects to send and receive data within a single SWF file,
but this is not a standard implementation; all the examples in this section illustrate
communication between different SWF files.
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; notice 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 a LocalConnection object is to allow communication only between
LocalConnection objects located in the same domain, since you wont 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 class
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 superdomain of the
location of the current SWF file.
LocalConnection.send() Invokes a method on a specified LocalConnection object.

Table of Contents

Related product manuals