LocalConnection.send( ) Method | Flash 6 |
invoke a method on a remote LocalConnection object |
The string name of the connection on which to invoke methodName, as set by the receiver's connect( ) method.
The string name of the method to invoke on the receiver. Must not be one of the following reserved words: "send", "connect", "close", "domain", "onStatus", or "allowDomain".
Optional arguments to pass to methodName.
A Boolean�true if the send( ) structure is syntactically correct, otherwise false.
The send( ) method sends a request to invoke the methodName at the connection specified by connectionName. The send( ) method can transfer a maximum of 40 KB of data. The optional arguments passed can be any datatype (Boolean, object, number, etc.). If an object is sent, its class is retained only if it is registered on both sides of the LocalConnection using Object.registerClass( ). See Object.registerClass( ) for more details.
When the sender and receiver movies are both loaded from the same domain, the connectionName for send( ) should simply match the connectionName specified by the receiver's connect( ) method. When the sender and receiver movies are loaded from different domains, the final connection name generated by Flash for the sender must match the final name generated for the receiver.
For the sender, the final connection name is generated as follows:
If the connectionName passed to send( ) does not start with an underscore ( _ ) and contains no colon (:), the sender's subdomain and a colon are prefixed to connectionName. For example, a connectionName of "channel1" resolves to a final name of "senderdomain.com:channel1" (where senderdomain.com is the subdomain of the sending movie).
If the connectionName passed to send( ) contains a colon, the specified value is used verbatim. For example, a connectionName of "moock.org:channel1" remains unchanged.
If the connectionName passed to send( ) starts with an underscore, the specified value is used verbatim. For example, a connectionName of "_channel1" remains unchanged.
For the receiver, the final connection name is generated as follows:
If the connectionName passed to connect( ) does not start with an underscore and contains no colon, the receiver's subdomain and a colon are prefixed to connectionName. For example, a connectionName of "channel1" resolves to a final name of "receiverdomain.com:channel1" (where receiverdomain.com is the subdomain of the receiving movie).
If the connectionName passed to connect( ) starts with an underscore, the specified value is used verbatim. For example, a connectionName of "_channel1" remains unchanged.
On the receiver, the connectionName format "moock.org:channel1" cannot be used (the receiver is not allowed to specify its own subdomain). Table 18-10 shows the specified and final connection name values for both the sender and receiver, and indicates whether each combination would match when the movies are running on the same domain or on different domains. For a full discussion of connection name matching, including overriding the security restrictions across domains, see LocalConnection.allowDomain( ).
Sender specified |
Sender final |
Receiver specified |
Receiver final |
Same domain match? |
Different domain match? |
---|---|---|---|---|---|
name |
senddomain:name |
name |
recdomain:name |
Yes |
No (The automatic subdomain prefixes would not match.) |
name |
senddomain:name |
_name |
_name |
No (No subdomain is used by the receiver.) |
No |
_name |
_name |
name |
recdomain:name |
No (No subdomain is used by the sender.) |
No |
_name |
_name |
_name |
_name |
Yes |
Yes (But allowDomain( ) must permit the connection.) |
subdomain:name |
subdomain:name |
name |
subdomain:name |
Yes, if sender's specified subdomain matches receiver's actual subdomain |
Yes (But allowDomain( ) must permit the connection, and sender's specified subdomain must match receiver's actual subdomain.) |
subdomain:name |
subdomain:name |
_name |
_name |
No (No subdomain is used by the receiver.) |
No |
LocalConnection.allowDomain( ), LocalConnection.connect( ), LocalConnection.domain( )