Localconnection.domain() - MACROMEDIA FLASH MX 2004-ACTIONSCRIPT LANGUAGE Reference

Actionscript language reference
Table of Contents

Advertisement

LocalConnection.domain()

Availability
Flash Player 6; behavior changed in Flash Player 7.
Usage
my_lc.domain() : String
Parameters
None.
Returns
A string representing the domain of the location of the current SWF file; for more information,
see the Description section.
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 computer, 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 with
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:
// If both the sending and receiving SWF files are Flash Player 6,
// then use the superdomain
var my_lc:LocalConnection = new LocalConnection();
my_lc.allowDomain = function(sendingDomain):String{
return (sendingDomain==this.domain() || sendingDomain=="macromedia.com");
}
// If either the sending or receiving SWF file is Flash Player 7 or later,
// then use the exact domain. In this case, commands from a SWF file posted
// at www.macromedia.com will be accepted, but those from one posted at
// a different subdomain, e.g. livedocs.macromedia.com, will not.
var my_lc:LocalConnection = new LocalConnection();
412
Chapter 2: ActionScript Language Reference
.
"www.macromedia.com"
LocalConnection.allowDomain
.
to accept commands from a

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash mx

Table of Contents