584
ActionScript classes
Example
In the following example, a SWF file creates a listener function named
Prefs
and then creates
a shared object. The player calls the
loadCompletePrefs
function when the data is available.
function loadCompletePrefs (SharedObject:mySO) {
if (0 == mySO.getSize() )
{
// If the size is 0, we need to initialize the data:
mySO.data.name = "Sigismund";
mySO.data.email = "[email protected]";
}
else
}
// Trace all the data in mySO:
trace( "Prefs:" );
for (var idx in mySO.data) {
trace( " " + idx +": " + mySO.data[idx] );
}
}
}
SharedObject.addListener( "Prefs", loadCompletePrefs );
// We can now create the shared object:
var Prefs:SharedObject = SharedObject.getLocal("Prefs");
When the player has notified the listener that the data is available, the application can use the
shared object returned from the call to the
getLocal()
method in the same way a shared
object is used in Flash. The application can add, modify, or remove properties while the
content is playing. When the content is unloaded, the shared object might be written to the
device; however, to guarantee that the shared object will be written to the device, the
application must force a write operation by calling the
flush()
method.
Flash Lite shared objects are available only to locally stored SWF files. SWF files playing back
in a network-enabled browser cannot use Flash Lite shared objects.
The total amount of storage for Flash Lite shared objects per SWF file is limited by the
deviceto a predetermined size. You can determine this size by using the
SharedObject.getMaxSize()
method.
Note:
Remote shared objects are not supported in Flash Lite 2.0.
See also
getLocal (SharedObject.getLocal method)
,
flush (SharedObject.flush method)
,
onStatus (SharedObject.onStatus handler)
Содержание Flash Lite 2
Страница 1: ...Flash Lite 2 x ActionScript Language Reference...
Страница 22: ...22 Contents...
Страница 244: ...244 ActionScript language elements...
Страница 760: ...760 ActionScript classes...