System.security.allowInsecureDomain()
441
// Corresponding commands to allow access by SWF files
// that are running in Flash Player 7 or later
System.security.allowDomain("www.domain.com", "store.domain.com");
Also, for files running in 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
System.security.allowInsecureDomain()
instead.
Occasionally, you might encounter the following situation: You load a child SWF file from a
different domain and want to allow the child SWF file to script 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
MovieClip._url
property as an argument to this method. For
example, if you load a SWF file into
my_mc
, you can call
System.security.allowDomain(my_mc._url)
.
If you do this, be sure to wait until the SWF file in
my_mc
is loaded, because the
_url
property
does not have its final, correct value until the file is completely loaded. The best way to determine
when a child SWF finishes loading is to use
MovieClipLoader.onLoadComplete
.
The opposite situation can also occur; that is, you might create a child SWF file that wants to
allow its parent to script it, but doesn’t know what the domain of its parent will be. In this
situation, call
System.security.allowDomain(_parent._url)
from the child SWF. In this
situation, you don’t have to wait for the parent SWF file to load; the parent will already be loaded
by the time the child loads.
Example
The SWF file located at www.macromedia.com/MovieA.swf contains the following lines:
System.security.allowDomain("www.shockwave.com");
loadMovie("http://www.shockwave.com/MovieB.swf", my_mc);
Because MovieA contains the
allowDomain()
command, MovieB can access the objects and
variables in MovieA. If MovieA didn’t contain this command, the Flash security implementation
would prevent MovieB from accessing MovieA’s objects and variables.
See also
MovieClip._url
,
MovieClipLoader.onLoadComplete
,
_parent
,
System.security.allowInsecureDomain()
System.security.allowInsecureDomain()
Availability
Flash Player 7.
Usage
System.security.allowInsecureDomain("
domain
"
:String
)
: Void
Parameters
domain
A string; an exact domain name, such as www.myDomainName.com or
store.myDomainName.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...