Use
LocalConnection.allowDomain
specified domains, or from any domain, to execute methods of the receiving LocalConnection
object. If you don't declare the sendingDomain parameter, you probably want to accept
commands from any domain, and the code in your handler would be simply return true. If
you do declare sendingDomain, you probably want to compare the value of sendingDomain
with domains from which you want to accept commands. The following examples show both
implementations.
In files authored for Flash Player 6, the
of the caller. In files authored for Flash Player 7 or later, the
contains the exact domain of the caller. In the latter case, to allow access by SWF files hosted
at either www.domain.com or store.domain.com, you must explicitly allow access from both
domains.
// For Flash Player 6
receiving_lc.allowDomain = function(sendingDomain) {
return(sendingDomain=="domain.com");
}
// For Flash Player 7 or later
receiving_lc.allowDomain = function(sendingDomain) {
return(sendingDomain=="www.domain.com" ||
sendingDomain=="store.domain.com");
}
Also, for files authored for Flash Player 7 or later, you can't use this method to let SWF files
hosted using a secure protocol (HTTPS) allow access from SWF files hosted in nonsecure
protocols; you must use the
instead.
Occasionally, you might encounter the following situation. Suppose you load a child SWF file
from a different domain. You want to implement this method so that the child SWF file can
make LocalConnection calls to the parent SWF file, but you don't know the final domain
from which the child SWF file will come. This can happen, for example, when you use load-
balancing redirects or third-party servers.
In this situation, you can use the
method. For example, if you load a SWF file into my_mc, you can then implement this
method by checking whether the domain argument matches the domain of
(You must parse the domain out of the full URL contained in
If you do this, make sure that you wait until the SWF file in
property will not have its final, correct value until the file is completely loaded. The best way
to determine when a child SWF file finishes loading is to use
MovieClipLoader.onLoadComplete
714
ActionScript classes
to explicitly permit LocalConnection objects from
sendingDomain
LocalConnection.allowInsecureDomain
MovieClip._url
.
parameter contains the superdomain
sendingDomain
property in your implementation of this
my_mc._url
is loaded, because the _url
my_mc
parameter
event handler
.
my_mc._url
.)
Need help?
Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?