
LocalConnection.allowDomain() Event Handler
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Alphabetical Language Reference
|
591
(“channel1”), the method to invoke (“displayMsg”), and the method argument(s) (“hello
world”), as follows:
sendConn.send("channel1", "displayMsg", "hello world");
Here is the complete code required to establish basic LocalConnection communication:
// CODE IN THE RECEIVING MOVIE
receiveConn = new LocalConnection();
receiveConn.methodName = function (param1, param2) {
// statements
}
receiveConn.connect("connectionName");
// CODE IN THE SENDING MOVIE
sendConn = new LocalConnection();
sendConn.send("connectionName", "methodName", "value1", "value2");
For security reasons, when the sender and receiver are posted at different domains, they
cannot, by default, communicate over a LocalConnection. See LocalConnection.
allowDomain( ) for details on allowing movies to communicate across domains. All movies
running on the local filesystem are considered in the same domain (“localhost”), and are
therefore not subject to security restrictions.
Communication over LocalConnection is many-to-one, from the sender’s perspective. Any
number of senders can send messages to a specific named connection, but only one receiver
can listen on that connection. If a different receiver tries to open a named connection that
is already open, ...