Recipe 17.8.
Controlling the Size of Local Shared Objects
Problem
You want
to control the amount of disk space used by a shared object.
Solution
Use the Security.showSettings( ) method
or visit the web site for the
Flash Player Settings Manager.
Discussion
As mentioned in Recipe 17.8, the default size
for an LSO is 100 KB. Recipe
17.3 explained that the flush( ) method can be used to
request a certain amount of disk space for an LSO. If the disk
space requested exceeds the maximum allowed value, the user is
prompted to either allow or deny the request. Through the use of
the flash.system.Security.showSettings( ) method, it is
possible to bring up a dialog that allows the user to set the
maximum amount of data allowed to be stored in an LSO. The
following code opens the Settings UI to the local disk storage
section.
// Show the settings for local storage
Security.showSettings( SecurityPanel.LOCAL_STORAGE );
To coincide with the Settings UI for a specific
domain, there is a more comprehensive Settings Manager that allows
a user to change to global settings. Athough the Settings UI and
Settings Manager provide similar functionality, they are completely
different items. The Settings UI is a special form inside the Flash
Player that is displayed via the showSettings( ) method,
allowing the user to control the settings for a specific domain.
The Settings UI can be opened through ActionScript as the preceding
code block shows. It can also be opened manually by
right/Control-clicking inside the Flash Player, and then selecting
Settings from the contextual menu. In contrast, the Settings
Manager is accessed via the macromedia.com web site. To open
the Settings Manager to the Website Storage form, go to
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager07.html.
This URL may look like just a simple a web page
or screenshot, but it's actually a functional Flash application
that modifies the global settings of the Flash Player. Updating a
value via the Settings Manager URL affects how the Flash Player
behaves. For instance, if you want to change the default size of an
LSO (for LSOs that have not been initially created yet), navigate
to the Global Storage Settings page (http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager03.html).
Adjust the slider until it displays an
acceptable value to you. After the slider value has been changed,
the default maximum size for LSOs has been modified.
Remember, as a developer you have no control
over LSO disk space on a client's computer. The best you can do is
request a certain amount of space, explain why you might need that
space, and hope that the user grants it to you. It is not
recommended, however, to rely on LSOs for functionality critical to
your application because the client has the final say of the LSO
sizeif the LSO is even
allowed at all.
|