LocalConnection.domain()
Availability
Flash Player 6; behavior changed in Flash Player 7.
Usage
my_lc.domain()
Parameters
None.
Returns
A string representing the domain of the location of the current SWF file; for details, see
"Description," below.
Description
Method; returns a string representing the domain of the location of the current SWF file.
In SWF files published for Flash Player 6, the returned string is the superdomain of the current
SWF file. For example, if the SWF file is located at www.macromedia.com, this command returns
"macromedia.com"
In SWF files published for Flash Player 7 or later, the returned string is the exact domain of the
current SWF file. For example, if the SWF file is located at www.macromedia.com, this
command returns
If the current SWF file is a local file residing on the client machine, this command returns
.
"localhost"
The most common way to use this command is to include the domain name of the sending
LocalConnection object as a parameter to the method you plan to invoke in the receiving
LocalConnection object, or in conjunction with
commands from a specified domain. If you are enabling communication only between
LocalConnection objects that are located in the same domain, you probably don't need to
use this command.
Example
In the following example, a receiving SWF file accepts commands only from SWF files located in
the same domain or at macromedia.com.
my_lc = new LocalConnection();
my_lc.allowDomain = function(sendingDomain)
{
return (sendingDomain==this.domain() || sendingDomain=="macromedia.com");
}
In the following example, a sending SWF file located at yourdomain.com invokes a method in a
receiving SWF file located at mydomain.com. The sending SWF file includes its domain name as
a parameter to the method it invokes, so the receiving SWF file can return a reply value to a
LocalConnection object in the correct domain. The sending SWF file also specifies that it will
accept commands only from SWF files at mydomain.com.
.
"www.macromedia.com"
.
LocalConnection.allowDomain
to accept
LocalConnection.domain()
441
Need help?
Do you have a question about the FLASH MX 2004 - ACTIONSCRIPT and is the answer not in the manual?
Questions and answers