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 />

applicationDomain: Use this property only wh<strong>en</strong> loading a SWF file writt<strong>en</strong> in ActionScript 3.0 (not an image or<br />

a SWF file writt<strong>en</strong> in ActionScript 1.0 or 2.0). Wh<strong>en</strong> loading the file, you can specify that the file be placed into a<br />

particular application domain, rather than the default of being placed in a new application domain that is a child of<br />

the loading SWF file’s application domain. Note that application domains are subunits of security domains, and<br />

thus you can specify a target application domain only if the SWF file that you are loading is from your own security<br />

domain, either because it is from your own server, or because you have successfully imported it into your security<br />

domain using the securityDomain property. If you specify an application domain but the loaded SWF file is part<br />

of a differ<strong>en</strong>t security domain, the domain you specify in applicationDomain is ignored. For more information,<br />

see “Working with application domains” on page 147.<br />

For details, see “Specifying loading context” on page 200.<br />

An important property of a Loader object is the cont<strong>en</strong>tLoaderInfo property, which is a LoaderInfo object. Unlike<br />

most other objects, a LoaderInfo object is shared betwe<strong>en</strong> the loading SWF file and the loaded cont<strong>en</strong>t, and it is always<br />

accessible to both parties. Wh<strong>en</strong> the loaded cont<strong>en</strong>t is a SWF file, it can access the LoaderInfo object through the<br />

DisplayObject.loaderInfo property. LoaderInfo objects include information such as load progress, the URLs of<br />

loader and loadee, the trust relationship betwe<strong>en</strong> loader and loadee, and other information. For more information, see<br />

“Monitoring loading progress” on page 199.<br />

Loading sound and videos<br />

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

Any cont<strong>en</strong>t, except cont<strong>en</strong>t in the local-with-filesystem sandbox, is allowed to load sound and video from network<br />

origins, using the Sound.load(), NetConnection.connect(), and NetStream.play() methods.<br />

Only cont<strong>en</strong>t in the local-with-filesystem and AIR application sandboxes can load media from the local file system.<br />

Only cont<strong>en</strong>t in the local-with-filesystem sandbox, the AIR application sandbox, or the local-trusted sandbox can<br />

access data in these loaded files.<br />

There are other restrictions on accessing data from loaded media. For details, see “Accessing loaded media as data” on<br />

page 1054.<br />

Loading SWF files and images using the tag in a text field<br />

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

You can load SWF files and bitmaps into a text field by using the tag, as in the following code:<br />

<br />

You can access cont<strong>en</strong>t loaded this way by using the getImageRefer<strong>en</strong>ce() method of the TextField instance, as in<br />

the following code:<br />

var loadedObject:DisplayObject = myTextField.getImageRefer<strong>en</strong>ce('instanceName');<br />

Note, however, that SWF files and images loaded in this way are put in the sandbox that corresponds to their origin.<br />

Wh<strong>en</strong> you load an image file using an tag in a text field, access to the data in the image may be permitted by a<br />

URL policy file. You can check for a policy file by adding a checkPolicyFile attribute to the tag, as in the<br />

following code:<br />

<br />

Wh<strong>en</strong> you load a SWF using an tag in a text field, you can permit access to that SWF file’s data through a call<br />

to the Security.allowDomain() method.<br />

Last updated 6/6/2012<br />

1050

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

Saved successfully!

Ooh no, something went wrong!