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

Storing local data<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

Storing typed objects in shared objects<br />

You can store typed ActionScript instances in shared objects. You do this by calling the<br />

flash.net.registerClassAlias() method to register the class. If you create an instance of your class and store it<br />

in the data member of your shared object and later read the object out, you will get a typed instance. By default, the<br />

SharedObject objectEncoding property supports AMF3 <strong>en</strong>coding, and unpacks your stored instance from the<br />

SharedObject object; the stored instance retains the same type you specified wh<strong>en</strong> you called the<br />

registerClassAlias() method.<br />

Creating multiple shared objects<br />

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

You can create multiple shared objects for the same Flex application. To do this, you assign each of them a differ<strong>en</strong>t<br />

instance name, as the following example shows:<br />

public var mySO:SharedObject = SharedObject.getLocal("prefer<strong>en</strong>ces");<br />

public var mySO2:SharedObject = SharedObject.getLocal("history");<br />

This creates a prefer<strong>en</strong>ces.sol file and a history.sol file in the Flex application’s local directory.<br />

Creating a secure SharedObject<br />

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

Wh<strong>en</strong> you create either a local or remote SharedObject using getLocal() or getRemote(), there is an optional<br />

parameter named secure that determines whether access to this shared object is restricted to SWF files that are<br />

delivered over an HTTPS connection. If this parameter is set to true and your SWF file is delivered over HTTPS, Flash<br />

Player creates a new secure shared object or gets a refer<strong>en</strong>ce to an existing secure shared object. This secure shared<br />

object can be read from or writt<strong>en</strong> to only by SWF files delivered over HTTPS that call SharedObject.getLocal()<br />

with the secure parameter set to true. If this parameter is set to false and your SWF file is delivered over HTTPS,<br />

Flash Player creates a new shared object or gets a refer<strong>en</strong>ce to an existing shared object.<br />

Last updated 6/6/2012<br />

707

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

Saved successfully!

Ooh no, something went wrong!