The AppSettings class is a singleton that holds a set of configuration
settings. Each setting consists of a key and a corresponding value.
The settings can be accessed (get and set) like properties of the
AppSettings class.
To add a setting or change the value of an existing setting, simply
define it as a property as follows:
AppSettings.getInstance().mySetting = "myValue";
To get a setting, request it as a property:
var result:String = AppSettings.getInstance().mySetting;
To delete a setting, use the delete operator:
delete AppSettings.getInstance().mySetting;
Author: Christophe Herreman
Version: $Revision: 21 $, $Date: 2008-11-01 22:58:42 +0100 (za, 01 nov 2008) $, $Author: dmurat $
Since: 0.1
public function AppSettings(enforcer:SingletonEnforcer)
Constructs a new instance of AppSettings.
Since this class is a singleton, the constructor should
never be called directly. (This is made impossible with the instance
of the internal SingletonEnforcer class that needs to be passed.)
To instantiate this class, call the static getInstance() method.
Parameters
| enforcer:SingletonEnforcer — An instance of the internal SingletonEnforcer class
to enforce a singleton
|
Throws
| — when instantiating with a 'null' argument
|
public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):voidParameters
| type:String |
| |
| listener:Function |
| |
| useCapture:Boolean (default = false) |
| |
| priority:int (default = 0) |
| |
| useWeakReference:Boolean (default = false) |
public function addListener(listener:IAppSettingsListener, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Adds a listener to the AppSettings.
Parameters
| listener:IAppSettingsListener — The listener object to be added
|
| |
| useCapture:Boolean (default = false) |
| |
| priority:int (default = 0) |
| |
| useWeakReference:Boolean (default = false) |
protected function AppSettingsInit(enforcer:SingletonEnforcer):void
Initializes the AppSettings instance
Parameters
| enforcer:SingletonEnforcer |
flash_proxy override function callProperty(methodName:*, ... args):*
Catches unknown method calls.
Parameters
Returns
flash_proxy override function deleteProperty(name:*):Boolean
Deletes a property.
Parameters
Returns
public function dispatchEvent(event:Event):BooleanParameters
Returns
public static function getInstance():AppSettings
Returns the singleton instance of the AppSettings class.
Returns
flash_proxy override function getProperty(name:*):*
Returns the value that matches the value with the given name.
Parameters
| name:* — The name of the setting you want to get.
|
Returns
public function hasEventListener(type:String):BooleanParameters
Returns
flash_proxy override function hasProperty(name:*):Boolean
Checks if a property exists.
Parameters
Returns
public function load(source:*):void
Loads an xml file or data containing the key/value pairs for the settings
and fills the AppSettings. The settings loaded from the xml file are
added to the existing settings and settings with the same key are
replaced by the new settings in the xml file.
The xml file can have any name you like or could even be generated
dynamically. The structure of the nodes should look as follows:
Parameters
| source:* — The location of the xml file that contains the appsettings or the XML object that contains the settings
|
protected function loadFromFile(url:String):void
Loads settings from an external xml file.
Parameters
| url:String — The location of the xml file that contains the settings.
|
flash_proxy override function nextName(index:int):String
Returns the name of the next property when looping through the
collection.
Parameters
Returns
flash_proxy override function nextNameIndex(index:int):int
Returns the index of the next property while looping through the
collection with a for or for each loop.
Parameters
Returns
flash_proxy override function nextValue(index:int):*
Returns the value of the next property when looping through the
collection.
Parameters
Returns
protected function parseSettingsFromXml(xml:XML):void
Parses the settings from the given XML instance.
Parameters
| xml:XML — The XML object that contains the settings.
|
public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):voidParameters
| type:String |
| |
| listener:Function |
| |
| useCapture:Boolean (default = false) |
public function removeListener(listener:IAppSettingsListener, useCapture:Boolean = false):void
Removes a listener from the AppSettings object.
Parameters
| listener:IAppSettingsListener — The listener object to be removed.
|
| |
| useCapture:Boolean (default = false) |
flash_proxy override function setProperty(name:*, value:*):void
Sets a property.
Parameters
public function willTrigger(type:String):BooleanParameters
Returns
protected function xmlLoaderComplete_handler(event:Event):void
Handles the Complete event of the URLLoader instance that loads
the XML data with the settings.
Parameters
Event object type: org.springextensions.actionscript.config.AppSettingsEvent
AppSettingsEvent.type property = org.springextensions.actionscript.config.AppSettingsEvent.LOAD
Dispatched when the external XML file has been loaded and parsed.
Copyright 2007-2010 Spring Actionscript.