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

Overview on configuring your HTML-based application<br />

Adobe AIR 1.0 and later<br />

Frames and iframes provide a conv<strong>en</strong>i<strong>en</strong>t structure for organizing HTML cont<strong>en</strong>t in AIR. Frames provide a means<br />

both for maintaining data persist<strong>en</strong>ce and for working securely with remote cont<strong>en</strong>t.<br />

Because HTML in AIR retains its normal, page-based organization, the HTML <strong>en</strong>vironm<strong>en</strong>t completely refreshes if<br />

the top frame of your HTML cont<strong>en</strong>t “navigates” to a differ<strong>en</strong>t page. You can use frames and iframes to maintain data<br />

persist<strong>en</strong>ce in AIR, much the same as you would for a web application running in a browser. Define your main<br />

application objects in the top frame and they persist as long as you don’t allow the frame to navigate to a new page. Use<br />

child frames or iframes to load and display the transi<strong>en</strong>t parts of the application. (There are a variety of ways to<br />

maintain data persist<strong>en</strong>ce that can be used in addition to, or instead of, frames. These include cookies, local shared<br />

objects, local file storage, the <strong>en</strong>crypted file store, and local database storage.)<br />

Because HTML in AIR retains its normal, blurred line betwe<strong>en</strong> executable code and data, AIR puts cont<strong>en</strong>t in the top<br />

frame of the HTML <strong>en</strong>vironm<strong>en</strong>t into the application sandbox. After the page load ev<strong>en</strong>t, AIR restricts any<br />

operations, such as eval(), that can convert a string of text into an executable object. This restriction is <strong>en</strong>forced ev<strong>en</strong><br />

wh<strong>en</strong> an application does not load remote cont<strong>en</strong>t. To allow HTML cont<strong>en</strong>t to execute these restricted operations, you<br />

must use frames or iframes to place the cont<strong>en</strong>t into a non-application sandbox. (Running cont<strong>en</strong>t in a sandboxed<br />

child frame may be necessary wh<strong>en</strong> using some JavaScript application frameworks that rely on the eval() function.)<br />

For a complete list of the restrictions on JavaScript in the application sandbox, see “Code restrictions for cont<strong>en</strong>t in<br />

differ<strong>en</strong>t sandboxes” on page 1071.<br />

Because HTML in AIR retains its ability to load remote, possibly insecure cont<strong>en</strong>t, AIR <strong>en</strong>forces a same-origin policy<br />

that prev<strong>en</strong>ts cont<strong>en</strong>t in one domain from interacting with cont<strong>en</strong>t in another. To allow interaction betwe<strong>en</strong><br />

application cont<strong>en</strong>t and cont<strong>en</strong>t in another domain, you can set up a bridge to serve as the interface betwe<strong>en</strong> a par<strong>en</strong>t<br />

and a child frame.<br />

Setting up a par<strong>en</strong>t-child sandbox relationship<br />

Adobe AIR 1.0 and later<br />

AIR adds the sandboxRoot and docum<strong>en</strong>tRoot attributes to the HTML frame and iframe elem<strong>en</strong>ts. These attributes<br />

let you treat application cont<strong>en</strong>t as if it came from another domain:<br />

Attribute Description<br />

sandboxRoot The URL to use for determining the sandbox and domain in which to place the<br />

frame cont<strong>en</strong>t. The file:, http:, or https: URL schemes must be used.<br />

docum<strong>en</strong>tRoot The URL from which to load the frame cont<strong>en</strong>t. The file:, app:, or appstorage:<br />

URL schemes must be used.<br />

The following example maps cont<strong>en</strong>t installed in the sandbox subdirectory of the application to run in the remote<br />

sandbox and the www.example.com domain:<br />

<br />

<br />

Last updated 6/6/2012<br />

1070

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

Saved successfully!

Ooh no, something went wrong!