SharedObject
1091
// Assign an empty string to myText_ti if the shared object is undefined
// to prevent the text input box from displaying "undefined" when
// this script is first run.
if (myText_ti.text == undefined) {
myText_ti.text = "";
}
// Create a listener object and function for <enter> event
var textListener:Object = new Object();
textListener.enter = function(eventObj:Object) {
my_so.data.myTextSaved = eventObj.target.text;
my_so.flush();
};
// Register the listener with the TextInput component instance
myText_ti.addEventListener("enter", textListener);
The following example saves the last frame that a user entered to a local shared object
kookie
:
// Get the kookie
var my_so:SharedObject = SharedObject.getLocal("kookie");
// Get the user of the kookie and go to the frame number saved for this
user.
if (my_so.data.user != undefined) {
this.user = my_so.data.user;
this.gotoAndStop(my_so.data.frame);
}
The following code block is placed on each SWF file frame:
// On each frame, call the rememberme function to save the frame number.
function rememberme() {
my_so.data.frame=this._currentframe;
my_so.data.user="John";
}
getSize (SharedObject.getSize method)
public getSize() : Number
Gets the current size of the shared object, in bytes.
Flash calculates the size of a shared object by stepping through all of its data properties; the
more data properties the object has, the longer it takes to estimate its size. Estimating object
size can take significant processing time, so you may want to avoid using this method unless
you have a specific need for it.
Availability:
ActionScript 1.0; Flash Player 6
Returns
Number
- A numeric value specifying the size of the shared object, in bytes.
Summary of Contents for FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
Page 1: ...ActionScript 2 0 Language Reference ...
Page 1352: ...1352 ActionScript classes ...