13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Security<br />

Loading data<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

Flash Player and AIR cont<strong>en</strong>t can exchange data with servers. Loading data is a differ<strong>en</strong>t kind of operation from<br />

loading media, because the loaded information appears as program objects, rather than being displayed as media.<br />

G<strong>en</strong>erally, cont<strong>en</strong>t may load data from the same domain that the cont<strong>en</strong>t originated from. However, cont<strong>en</strong>t usually<br />

requires policy files in order to load data from other domains (see “Website controls (policy files)” on page 1040).<br />

Note: Cont<strong>en</strong>t running in the AIR application sandbox is never served from a remote domain (unless the developer<br />

int<strong>en</strong>tionally imports remote cont<strong>en</strong>t into the application sandbox), so it cannot participate in the types of attacks that<br />

policy files protect against. AIR cont<strong>en</strong>t in the application sandbox is not restricted from loading data by policy files.<br />

However, AIR cont<strong>en</strong>t in other sandboxes is subject to the restrictions described here.<br />

Using URLLoader and URLStream<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

You can load data, such as an XML file or a text file. The load() methods of the URLLoader and URLStream classes<br />

are governed by URL policy file permissions.<br />

If you use the load() method to load cont<strong>en</strong>t from a domain other than that of the code that is calling the method,<br />

the runtime checks for a URL policy file on the server of the loaded assets. If there is a policy file, and it grants access<br />

to the domain of the loading cont<strong>en</strong>t, you can load the data.<br />

Connecting to sockets<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

By default, the runtime looks for a socket policy file served from port 843. As with URL policy files, this file is called<br />

the master policy file.<br />

Wh<strong>en</strong> policy files were first introduced in Flash Player 6, there was no support for socket policy files. Connections to<br />

socket servers were authorized by a policy file in the default location on an HTTP server on port 80 of the same host<br />

as the socket server. Flash Player 9 still supports this capability, but Flash Player 10 does not. In Flash Player 10, only<br />

socket policy files can authorize socket connections.<br />

Like URL policy files, socket policy files support a meta-policy statem<strong>en</strong>t that specifies which ports can serve policy<br />

files. However, instead of “master-only,” the default meta-policy for socket policy files is “all.” That is, unless the<br />

master policy file specifies a more restrictive setting, Flash Player assumes that any socket on the host can serve a socket<br />

policy file.<br />

Access to socket and XML socket connections is disabled by default, ev<strong>en</strong> if the socket you are connecting to is in the<br />

same domain as the SWF file. You can permit socket-level access by serving a socket policy file from any of the<br />

following locations:<br />

Port 843 (the location of the master policy file)<br />

The same port as the main socket connection<br />

A differ<strong>en</strong>t port than the main socket connection<br />

By default, Flash Player looks for a socket policy file on port 843 and on the same port as the main socket connection.<br />

If you want to serve a socket policy file from a differ<strong>en</strong>t port, the SWF file must call Security.loadPolicyFile().<br />

Last updated 6/6/2012<br />

1057

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!