LocalData

Kind of class:class
Inherits from:none
Author:Martijn de Visser
Classpath:org.asapframework.util.system.LocalData
File last modified:Thursday, 12 October 2006, 11:19:40
A class for storing typed data locally. Wraps the SharedObject class.
Based on Colin Moock's class - http://moock.org/asdg/technotes/saveDataToDisk/
Example:
  • // Check if user has visited the site before
    var visited:Object = LocalData.loadField("MySite", "visited");
    if (visited && Boolean(visited) == true) {
        // do visited code
        // ...
    } else {
        // do first time visit code
        // ...
        // Now store 'visited' tag for later user
        LocalData.saveField("MySite", "visited", true);
    }

Summary


Constructor
Class methods
  • saveSOL (inRecord:String, inData:Object, inPath:String) : Void
    • Saves a single value to disk using a SharedObject instance.
  • loadSOL (inRecord:String, inPath:String) : Object
    • Retrieves a single value from disk using a SharedObject instance.
  • clearSOL (inRecord:String, inPath:String) : Void
    • Clears the SharedObject instance; on Flash Player 7 the instance is cleared from disk, on lower players all properties are deleted from the object
  • saveField (inRecord:String, inField:String, inData:Object, inPath:String) : Void
    • Saves a single value to disk using a SharedObject instance.
  • loadField (inRecord:String, inField:String, inPath:String) : Object
    • Retrieves a single value from disk using a SharedObject instance.
  • toString : String

Constructor

LocalData

private function LocalData (
)

Private constructor: it is not possible to instantiate a LocalData instance. Call the static methods instead.

Class methods

clearSOL

static function clearSOL (
inRecord:String, inPath:String) : Void

Clears the SharedObject instance; on Flash Player 7 the instance is cleared from disk, on lower players all properties are deleted from the object
Parameters:
inRecord:
String, the name of the record to be cleared
inPath :
(optional) The path to the SharedObject on disk which restricts this record to the swf that saves the data. Leave empty for default path.

loadField

static function loadField (
inRecord:String, inField:String, inPath:String) : Object

Retrieves a single value from disk using a SharedObject instance.
Parameters:
inRecord:
String, the name of the record to retrieve
inField :
String, the specific field to retrieve within the specified record
inPath :
(optional) String, the path to the cookie on disk, leave empty for default path, which restricts this record to the swf that saves the data
Returns:
  • Object, The value of the specified field.

loadSOL

static function loadSOL (
inRecord:String, inPath:String) : Object

Retrieves a single value from disk using a SharedObject instance.
Parameters:
inRecord:
String, The name of the record to retrieve.
inPath :
(optional) The path to the SharedObject on disk which restricts this record to the swf that saves the data. Leave empty for default path.
Returns:
  • Object, The value of the specified record.

saveField

static function saveField (
inRecord:String, inField:String, inData:Object, inPath:String) : Void

Saves a single value to disk using a SharedObject instance.
Parameters:
inRecord:
String, The name of the record to save.
inField :
String, The specific field to save within the specified record.
inData :
 
inPath :
(optional) String, the path to the cookie on disk, leave empty for default path, which restricts this record to the swf that saves the data

saveSOL

static function saveSOL (
inRecord:String, inData:Object, inPath:String) : Void

Saves a single value to disk using a SharedObject instance.
Parameters:
inRecord:
the name of the record to save
inData :
the data to save
inPath :
(optional) The path to the SharedObject on disk which restricts this record to the swf that saves the data. Leave empty for default path.

toString

static function toString (
) : String