Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 383

Programming actionscript 3.0
Table of Contents

Advertisement

}
public function closeHandler(event:TimerEvent):void
{
fscommand("quit");
}
}
}
To create a LocalConnection server, call the
provide a unique connection name. If you already have a connection with the specified name,
an
error is generated, indicating that the connection attempt failed because
ArgumentError
the object is already connected.
The following snippet demonstrates how to create a new socket connection with the name
:
conn1
try
{
connection.connect("conn1");
}
catch (error:ArgumentError)
{
trace("Error! Server already exists\n");
}
In earlier versions of ActionScript, the
Boolean value if the connection name has already been used. In ActionScript 3.0, an
error is generated if the name has already been used.
Connecting to the primary SWF file from a secondary SWF file requires that you create a new
LocalConnection object in the sending LocalConnection object and then call the
LocalConnection.send()
method to execute. For example, to connect to the LocalConnection object that you created
earlier, you use the following code:
sendingConnection.send("conn1", "doQuit");
This code connects to an existing LocalConnection object with the connection name
and invokes the
doQuit()
the remote SWF file, you specify additional arguments after the method name in the
method, as the following snippet shows:
sendingConnection.send("conn1", "doMessage", "Hello world");
LocalConnection.connect()
LocalConnection.connect()
method with the name of the connection and the name of the
method in the remote SWF file. If you want to send parameters to
Connecting to other Flash Player instances
method and
method returns a
conn1
send()
383

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents