Dispatch an event when config values change.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4603 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -22,11 +22,12 @@
|
|||||||
package com.threerings.util {
|
package com.threerings.util {
|
||||||
|
|
||||||
import flash.events.NetStatusEvent;
|
import flash.events.NetStatusEvent;
|
||||||
|
import flash.events.EventDispatcher;
|
||||||
|
|
||||||
import flash.net.SharedObject;
|
import flash.net.SharedObject;
|
||||||
import flash.net.SharedObjectFlushStatus;
|
import flash.net.SharedObjectFlushStatus;
|
||||||
|
|
||||||
public class Config
|
public class Config extends EventDispatcher
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Constructs a new config object which will obtain configuration
|
* Constructs a new config object which will obtain configuration
|
||||||
@@ -53,6 +54,9 @@ public class Config
|
|||||||
{
|
{
|
||||||
_so.data[name] = value;
|
_so.data[name] = value;
|
||||||
_so.flush(); // flushing is not strictly necessary
|
_so.flush(); // flushing is not strictly necessary
|
||||||
|
|
||||||
|
// dispatch an event corresponding
|
||||||
|
dispatchEvent(new ConfigValueSetEvent(name, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.threerings.util {
|
||||||
|
|
||||||
|
import flash.events.Event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dispatched whenever a config value is changed.
|
||||||
|
*/
|
||||||
|
public class ConfigValueSetEvent extends Event
|
||||||
|
{
|
||||||
|
/** The type of a ConfigValueSetEvent. */
|
||||||
|
public static const TYPE :String = "ConfigValSet";
|
||||||
|
|
||||||
|
/** The name of the config value set. */
|
||||||
|
public var name :String;
|
||||||
|
|
||||||
|
/** The new value. */
|
||||||
|
public var value :Object;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public function ConfigValueSetEvent (name :String, value :Object)
|
||||||
|
{
|
||||||
|
super(TYPE);
|
||||||
|
|
||||||
|
this.name = name;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
override public function clone () :Event
|
||||||
|
{
|
||||||
|
return new ConfigValueSetEvent(name, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user