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

Storing local data<br />

Wh<strong>en</strong> you create a shared object, Flash Player creates a new directory for the application and domain inside its<br />

sandbox. It also creates a *.sol file that stores the SharedObject data. The default location of this file is a subdirectory<br />

of the user’s home directory. The following table shows the default locations of this directory:<br />

Operating System Location<br />

Windows<br />

95/98/ME/2000/XP<br />

c:/Docum<strong>en</strong>ts and Settings/username/Application<br />

Data/Macromedia/Flash Player/#SharedObjects<br />

Windows Vista c:/Users/username/AppData/Roaming/Macromedia/Flash<br />

Player/#SharedObjects<br />

Macintosh OS X /Users/username/Library/Prefer<strong>en</strong>ces/Macromedia/Flash<br />

Player/#SharedObjects/web_domain/path_to_application/applicatio<br />

n_name/object_name.sol<br />

Linux/Unix /home/username/.macromedia/Flash_Player/#SharedObjects/web_doma<br />

in/path_to_application/application_name/object_name.sol<br />

Below the #SharedObjects directory is a randomly-named directory. Below that is a directory that matches the<br />

hostname, th<strong>en</strong> the path to the application, and finally the *.sol file.<br />

For example, if you request an application named MyApp.swf on the local host, and within a subdirectory named /sos,<br />

Flash Player stores the *.sol file in the following location on Windows XP:<br />

c:/Docum<strong>en</strong>ts and Settings/fred/Application Data/Macromedia/Flash<br />

Player/#SharedObjects/KROKWXRK/#localhost/sos/MyApp.swf/data.sol<br />

Note: If you do not provide a name in the SharedObject.getLocal() method, Flash Player names the file<br />

undefined.sol.<br />

By default, Flash can save locally persist<strong>en</strong>t SharedObject objects of up to 100 KB per domain. This value is userconfigurable.<br />

Wh<strong>en</strong> the application tries to save data to a shared object that would make it bigger than 100 KB, Flash<br />

Player displays the Local Storage dialog box, which lets the user allow or d<strong>en</strong>y more local storage for the domain that<br />

is requesting access.<br />

Specifying a path<br />

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

You can use the optional pathname parameter to specify a location for the SharedObject file. This file must be a<br />

subdirectory of that domain’s SharedObject directory. For example, if you request an application on the localhost and<br />

specify the following:<br />

mySO = SharedObject.getLocal("myObjectFile","/");<br />

Flash Player writes the SharedObject file in the /#localhost directory (or /localhost if the application is offline). This is<br />

useful if you want more than one application on the cli<strong>en</strong>t to be able to access the same shared object. In this case, the<br />

cli<strong>en</strong>t could run two Flex applications, both of which specify a path to the shared object that is the root of the domain;<br />

the cli<strong>en</strong>t could th<strong>en</strong> access the same shared object from both applications. To share data betwe<strong>en</strong> more than<br />

application without persist<strong>en</strong>ce, you can use the LocalConnection object.<br />

If you specify a directory that does not exist, Flash Player does not create a SharedObject file.<br />

Last updated 6/6/2012<br />

702

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

Saved successfully!

Ooh no, something went wrong!