MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE Reference page 1081

Actionscript 2.0 language reference
Table of Contents

Advertisement

Local shared objects maintain local persistence. For example, you can call
SharedObject.getLocal()
Because the shared object is locally persistent, Flash saves its data attributes on the user's
computer when the game is closed. The next time the game is opened, the high score from the
previous session is displayed. Alternatively, you could set the shared object's properties to
before the game is closed. The next time the SWF file runs, the game opens without the
null
previous high score.
To create a local shared object, use the following syntax:
var so:SharedObject = SharedObject.getLocal("userHighScore");
so.data.highScore = new Number();
so.flush();
In the example, the shared object is explicitly flushed, or written to a disk. When an
application closes, shared objects are automatically flushed; however, it is shown here to
demonstrate the step of writing data to a disk.
Local disk space considerations: Local shared objects can be very useful, but they have some
limitations that are important to consider as you design your application. Sometimes your
SWF files may not be allowed to write local shared objects, and sometimes the data stored in
local shared objects can be deleted without your knowledge. Flash Player users can manage the
disk space that is available to individual domains or to all domains. When users lower the
amount of disk space available, some local shared objects may be deleted. Flash Player users
also have privacy controls that can prevent third-party domains (domains other than the
domain in the current browser address bar) from reading or writing local shared objects.
Local content can always write third-party shared objects to disk, even if writing of
shared objects to disk by third-party domains is disallowed.
Macromedia recommends that you check for failures that are related to the amount of disk
space available and to user privacy controls. Perform these checks when you call
and
:
flush()
SharedObject.getLocal()
third-party shared objects and the domain of your SWF file does not match the domain in
the browser address bar.
SharedObject.flush()
shared objects for your domain or for all domains. It returns
storage space is needed and the user must interactively decide whether to allow an
increase.
to create a shared object that contains the high score in a game.
— This method returns
— This method returns
when the user has disabled
null
when the user has disabled
false
"pending"
SharedObject
getLocal()
when additional
1081

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash 8

Table of Contents