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 embedded cont<strong>en</strong>t from SWF files imported<br />

into a security domain<br />

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

Wh<strong>en</strong> you load a SWF file, you can set the context parameter of the load() method of the Loader object that is used<br />

to load the file. This parameter takes a LoaderContext object. Wh<strong>en</strong> you set the securityDomain property of this<br />

LoaderContext object to Security.curr<strong>en</strong>tDomain, Flash Player checks for a URL policy file on the server of the<br />

loaded SWF file. If there is a policy file, and it grants access to the domain of the loading SWF file, you can load the<br />

SWF file as imported media. In this way, the loading file can get access to objects in the library of the SWF file.<br />

An alternative way for a SWF file to access classes in loaded SWF files from a differ<strong>en</strong>t security sandbox is to have the<br />

loaded SWF file call the Security.allowDomain() method to grant access to the domain of the calling SWF file. You<br />

can add the call to the Security.allowDomain() method to the constructor method of the main class of the loaded<br />

SWF file, and th<strong>en</strong> have the loading SWF file add an ev<strong>en</strong>t list<strong>en</strong>er to respond to the init ev<strong>en</strong>t dispatched by the<br />

cont<strong>en</strong>tLoaderInfo property of the Loader object. Wh<strong>en</strong> this ev<strong>en</strong>t is dispatched, the loaded SWF file has called the<br />

Security.allowDomain() method in the constructor method, and classes in the loaded SWF file are available to the<br />

loading SWF file. The loading SWF file can retrieve classes from the loaded SWF file by calling<br />

Loader.cont<strong>en</strong>tLoaderInfo.applicationDomain.getDefinition() or<br />

Loader.cont<strong>en</strong>tLoaderInfo.applicationDomain.getQualifiedDefinitionNames()(Flash Player 11.3 and higher; AIR 3.3<br />

and higher).<br />

Working with legacy cont<strong>en</strong>t<br />

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

In Flash Player 6, the domain that is used for certain Flash Player settings is based on the trailing portion of the domain<br />

of the SWF file. These settings include settings for camera and microphone permissions, storage quotas, and storage<br />

of persist<strong>en</strong>t shared objects.<br />

If the domain of a SWF file includes more than two segm<strong>en</strong>ts, such as www.example.com, the first segm<strong>en</strong>t of the<br />

domain (www) is removed, and the remaining portion of the domain is used. So, in Flash Player 6, www.example.com<br />

and store.example.com both use example.com as the domain for these settings. Similarly, www.example.co.uk and<br />

store.example.co.uk both use example.co.uk as the domain for these settings. This can lead to problems in which SWF<br />

files from unrelated domains, such as example1.co.uk and example2.co.uk, have access to the same shared objects.<br />

In Flash Player 7 and later, player settings are chos<strong>en</strong> by default according to a SWF file’s exact domain. For example,<br />

a SWF file from www.example.com would use the player settings for www.example.com. A SWF file from<br />

store.example.com would use the separate player settings for store.example.com.<br />

In a SWF file writt<strong>en</strong> using ActionScript 3.0, wh<strong>en</strong> Security.exactSettings is set to true (the default), Flash Player<br />

uses exact domains for player settings. Wh<strong>en</strong> it is set to false, Flash Player uses the domain settings used in Flash<br />

Player 6. If you change exactSettings from its default value, you must do so before any ev<strong>en</strong>ts occur that require<br />

Flash Player to choose player settings—for example, using a camera or microphone, or retrieving a persist<strong>en</strong>t shared<br />

object.<br />

If you published a version 6 SWF file and created persist<strong>en</strong>t shared objects from it, to retrieve those persist<strong>en</strong>t shared<br />

objects from a SWF that uses ActionScript 3.0, you must set Security.exactSettings to false before calling<br />

SharedObject.getLocal().<br />

Last updated 6/6/2012<br />

1060

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

Saved successfully!

Ooh no, something went wrong!