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

They are transmitted from cli<strong>en</strong>t to server through HTTP.<br />

In contrast, shared objects have the following properties:<br />

They do not expire by default.<br />

By default, they are limited to a size of 100 KB each.<br />

They can store simple data types (such as String, Array, and Date).<br />

They are stored in a location specified by the application (within the user’s home directory).<br />

They are never transmitted betwe<strong>en</strong> the cli<strong>en</strong>t and server.<br />

About the SharedObject class<br />

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

Using the SharedObject class, you can create and delete shared objects, as well as detect the curr<strong>en</strong>t size of a<br />

SharedObject object that you are using. The SharedObject class consists of the following methods.<br />

Method Description<br />

clear() Purges all of the data from the SharedObject object, and deletes the SharedObject file from the<br />

disk.<br />

flush() Immediately writes the SharedObject file to a file on the cli<strong>en</strong>t.<br />

getLocal() Returns a refer<strong>en</strong>ce to the cli<strong>en</strong>t’s domain-specific, local SharedObject object. If none exists, this<br />

method creates a new shared object on the cli<strong>en</strong>t.<br />

getSize() Gets the size of the SharedObject file, in bytes. The default size limit is 100 KB, although it can<br />

be larger if the cli<strong>en</strong>t allows it.<br />

In addition to these methods, SharedObject objects have the following properties:<br />

Property Description<br />

data Read-only property that repres<strong>en</strong>ts the collection of attributes the shared object stores.<br />

onStatus The shared object’s ev<strong>en</strong>t handler that is invoked for every warning, error, or informational<br />

note.<br />

Creating a shared object<br />

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

To create a SharedObject object, use the SharedObject.getLocal() method, which has the following syntax:<br />

SharedObject.getLocal("objectName" [, pathname]): SharedObject<br />

The following example creates a shared object called mySO:<br />

public var mySO:SharedObject;<br />

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

This creates a file on the cli<strong>en</strong>t’s machine called prefer<strong>en</strong>ces.sol.<br />

The term local refers to the location of the shared object. In this case, Adobe® Flash® Player stores the SharedObject file<br />

locally in the cli<strong>en</strong>t’s home directory.<br />

Last updated 6/6/2012<br />

701

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

Saved successfully!

Ooh no, something went wrong!