Client-Side Communication ActionScript > LocalConnection.allowDomain |
![]() ![]() ![]() |
LocalConnection.allowDomain
Availability
![]() |
Flash Player 6. |
![]() |
Flash Communication Server MX (not required). |
Usage
receivingLC
.allowDomain = function([sendingDomain
]
) { // Your code here returns true or false }
Parameters
sendingDomain
An optional parameter specifying the subdomain of the movie containing the sending LocalConnection object.
Returns
Nothing.
Description
Event handler; invoked whenever receivingLC
receives a request to invoke a method from a sending LocalConnection object. Flash expects the code you implement in this handler to return a Boolean value of true
or false
. If the handler doesn't return true
, the request from the sending object is ignored, and the method is not invoked.
Use this command to explicitly permit LocalConnection objects from specified domains, or from any domain, to execute methods of the receiving LocalConnection object. If you don't pass a value for sendingDomain
, you probably want to accept commands from any domain, and the code in your handler would simply be return true
. If you do pass a value for sendingDomain
, you probably want to compare the value of sendingDomain
with domains from which you want to accept commands. Both of these implementations are illustrated in the following examples.
Example
The following example shows how a LocalConnection object in a receiving movie can permit movies from any domain to invoke its methods. Compare this to the example in LocalConnection.connect
, in which only movies from the same domain can invoke the Trace
method in the receiving movie. For a discussion of the use of the underscore (_) in the connection name, see LocalConnection.send
.
var aLocalConnection = new LocalConnection(); aLocalConnection.Trace = function(aString) { aTextField = aTextField + aString + newline; } aLocalConnection.allowDomain = function() { // any domain can invoke methods on this LocalConnection object return true; } aLocalConnection.connect("_trace");
In the following example, the receiving movie accepts commands only from movies located in thisDomain.com or thatDomain.com.
var aLocalConnection = new LocalConnection(); aLocalConnection.Trace = function(aString) { aTextField = aTextField + aString + newline; } aLocalConnection.allowDomain = function(sendingDomain) { return(sendingDomain=="thisDomain.com" || sendingDomain=="thatDomain.com"); } aLocalConnection.connect("_trace");
See also
LocalConnection.connect
, LocalConnection.domain
, LocalConnection.send
![]() ![]() ![]() |