Flash Lite 2.x and 3.0 ActionScript Language Reference

onStatus (SharedObject.onStatus handler)

onStatus = function(infoObject:Object) {}

Invoked every time an error, warning, or informational note is posted for a shared object. To respond to this event handler, you must create a function to process the information object that is generated by the shared object.

The information object has a code property that contsins a string that describes the result of the onStatus handler, and a level property that contains a string that is either "Status" or "Error".

In addition to this handler, Flash Lite also provides a super function called System.onStatus. If onStatus is invoked for a particular object and no function is assigned to respond to it, Flash Lite processes a function assigned to System.onStatus, if it exists.

The following events notify you when certain SharedObject activities occur:

Code property

Level property

Meaning

SharedObject.Flush.Failed

Error

SharedObject.flush() method that returned "pending" has failed (the user did not allot additional disk space for the shared object when Flash Player showed the Local Storage Settings dialog box).

SharedObject.Flush.Success

Status

SharedObject.flush() method that returned "pending" was successfully completed (the user allotted additional disk space for the shared object).

Parameters

infoObject:Object - A parameter defined according to the status message.

Example

The following example displays different messages based on whether the user chooses to allow or deny the SharedObject instance to write to the disk.

this.createTextField("message_txt", this.getNextHighestDepth(), 0, 30, 120, 50);
this.message_txt.wordWrap = true;

this.createTextField("status_txt", this.getNextHighestDepth(), 0, 90, 120, 100);
this.status_txt.wordWrap = true;

var items_array:Array = new Array(101, 346, 483);
var currentUserIsAdmin:Boolean = true;
var currentUserName:String = "Ramona";
var my_so:SharedObject = SharedObject.getLocal("superfoo");
my_so.data.itemNumbers = items_array;
my_so.data.adminPrivileges = currentUserIsAdmin;
my_so.data.userName = currentUserName;

my_so.onStatus = function(infoObject:Object) {
    for (var i in infoObject) {
    status_txt.text += i+"-"+infoObject[i] +"\n";
    }
};

var flushResult = my_so.flush(1000001);
switch (flushResult) {
    case 'pending' :
    message_txt.text = "flush is pending, waiting on user interaction.";
    break;
    case true :
    message_txt.text = "flush was successful. Requested storage space approved.";
    break;
    case false :
    message_txt.text = "flush failed. User denied request for additional storage.";
    break;
}

See also

onStatus (System.onStatus handler)