Added a really basic Config class for storing prefs clientside,

wired it up.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4184 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-06-08 22:12:19 +00:00
parent e6e96c25fc
commit d948eb4f37
3 changed files with 62 additions and 4 deletions
+46
View File
@@ -0,0 +1,46 @@
package com.threerings.util {
import flash.net.SharedObject;
public class Config
{
/**
* Constructs a new config object which will obtain configuration
* information from the specified path.
*/
public function Config (path :String)
{
_so = SharedObject.getLocal("config_" + path, "/");
}
/**
* Fetches and returns the value for the specified configuration property.
*/
public function getValue (name :String, defValue :Object) :Object
{
var val :* = _so.data[name];
return (val === undefined) ? defValue : val;
}
/**
* Returns the value specified.
*/
public function setValue (name :String, value :Object) :void
{
_so.data[name] = value;
_so.flush(); // flushing is not strictly necessary
}
/**
* Remove any set value for the specified preference.
*/
public function remove (name :String) :void
{
delete _so.data[name];
_so.flush(); // flushing is not strictly necessary
}
/** The shared object that contains our preferences. */
protected var _so :SharedObject;
}
}