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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

Security<br />

Another elem<strong>en</strong>t you can use to permit access is the allow-http-request-headers-from tag. This elem<strong>en</strong>t grants<br />

a cli<strong>en</strong>t hosting cont<strong>en</strong>t from another permission domain to s<strong>en</strong>d user-defined headers to your domain. While the<br />

tag grants other domains permission to pull data from your domain, the allow-httprequest-headers-from<br />

tag grants other domains permission to push data to your domain, in the form of headers.<br />

In the following example, any domain is permitted to s<strong>en</strong>d the SOAPAction header to the curr<strong>en</strong>t domain:<br />

<br />

<br />

<br />

If the allow-http-request-headers-from statem<strong>en</strong>t is in the master policy file, it applies to all directories on the<br />

host. Otherwise, it applies only to the directory and subdirectories of the policy file that contains the statem<strong>en</strong>t.<br />

Preloading policy files<br />

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

Loading data from a server or connecting to a socket is an asynchronous operation. Flash Player simply waits for the<br />

policy file to finish downloading before it begins the main operation. However, extracting pixel data from images or<br />

extracting sample data from sounds is a synchronous operation. The policy file must load before you can extract data.<br />

Wh<strong>en</strong> you load the media, specify that it check for a policy file:<br />

Wh<strong>en</strong> using the Loader.load() method, set the checkPolicyFile property of the context parameter, which is<br />

a LoaderContext object.<br />

Wh<strong>en</strong> embedding an image in a text field using the tag, set the checkPolicyFile attribute of the tag<br />

to "true", as in the following:<br />

<br />

Wh<strong>en</strong> using the Sound.load() method, set the checkPolicyFile property of the context parameter, which is a<br />

SoundLoaderContext object.<br />

Wh<strong>en</strong> using the NetStream class, set the checkPolicyFile property of the NetStream object.<br />

Wh<strong>en</strong> you set one of these parameters, Flash Player first checks for any policy files that it already has downloaded for<br />

that domain. Th<strong>en</strong> it looks for the policy file in the default location on the server, checking both for <br />

statem<strong>en</strong>ts and for the pres<strong>en</strong>ce of a meta-policy. Finally, it considers any p<strong>en</strong>ding calls to the<br />

Security.loadPolicyFile() method to see if they are in scope.<br />

Author (developer) controls<br />

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

The main ActionScript API used to grant security privileges is the Security.allowDomain() method, which grant<br />

privileges to SWF files in the domains that you specify. In the following example, a SWF file grants access to SWF files<br />

served from the www.example.com domain:<br />

Security.allowDomain("www.example.com")<br />

This method grants permissions for the following:<br />

Cross-scripting betwe<strong>en</strong> SWF files (see “Cross-scripting” on page 1051)<br />

Display list access (see “Traversing the display list” on page 1053)<br />

Ev<strong>en</strong>t detection (see “Ev<strong>en</strong>t security” on page 1054)<br />

Full access to properties and methods of the Stage object (see “Stage security” on page 1052)<br />

Last updated 6/6/2012<br />

1043

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

Saved successfully!

Ooh no, something went wrong!