338
Chapter 6: ActionScript Core Classes
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
"www.macromedia.com"
.
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
LocalConnection.allowDomain
to accept 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:
// 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();
my_lc.allowDomain = function(sendingDomain):String{
return (sendingDomain==this.domain() ||
sendingDomain=="www.macromedia.com");
}
In the following example, a sending SWF file located at www.yourdomain.com invokes a method
in a receiving SWF file located at www.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.
Summary of Contents for FLEX-FLEX ACTIONSCRIPT LANGUAGE
Page 1: ...Flex ActionScript Language Reference...
Page 8: ......
Page 66: ...66 Chapter 2 Creating Custom Classes with ActionScript 2 0...
Page 76: ......
Page 133: ...break 133 See also for for in do while while switch case continue throw try catch finally...
Page 135: ...case 135 See also break default strict equality switch...
Page 146: ...146 Chapter 5 ActionScript Core Language Elements See also break continue while...
Page 808: ...808 Chapter 7 ActionScript for Flash...
Page 810: ...810 Appendix A Deprecated Flash 4 operators...
Page 815: ...Other keys 815 Num Lock 144 186 187 _ 189 191 192 219 220 221 222 Key Key code...
Page 816: ...816 Appendix B Keyboard Keys and Key Code Values...
Page 822: ...822 Index...