Packageorg.springextensions.actionscript.config
SVN browsingAppSettings.as
FisheyeAppSettings.as
Classpublic dynamic class AppSettings
InheritanceAppSettings Inheritance flash.utils.Proxy
Implementsflash.events.IEventDispatcher

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 Methods
 MethodDefined by
  
AppSettings(enforcer:SingletonEnforcer)
Constructs a new instance of AppSettings.
AppSettings
  
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
AppSettings
  
addListener(listener:IAppSettingsListener, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Adds a listener to the AppSettings.
AppSettings
  
dispatchEvent(event:Event):Boolean
AppSettings
  
[static] Returns the singleton instance of the AppSettings class.
AppSettings
  
hasEventListener(type:String):Boolean
AppSettings
  
load(source:*):void
Loads an xml file or data containing the key/value pairs for the settings and fills the AppSettings.
AppSettings
  
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
AppSettings
  
removeListener(listener:IAppSettingsListener, useCapture:Boolean = false):void
Removes a listener from the AppSettings object.
AppSettings
  
willTrigger(type:String):Boolean
AppSettings
Protected Methods
 MethodDefined by
  
AppSettingsInit(enforcer:SingletonEnforcer):void
Initializes the AppSettings instance
AppSettings
  
callProperty(methodName:*, ... args):*
Catches unknown method calls.
AppSettings
  
deleteProperty(name:*):Boolean
Deletes a property.
AppSettings
  
getProperty(name:*):*
Returns the value that matches the value with the given name.
AppSettings
  
hasProperty(name:*):Boolean
Checks if a property exists.
AppSettings
  
loadFromFile(url:String):void
Loads settings from an external xml file.
AppSettings
  
nextName(index:int):String
Returns the name of the next property when looping through the collection.
AppSettings
  
nextNameIndex(index:int):int
Returns the index of the next property while looping through the collection with a for or for each loop.
AppSettings
  
nextValue(index:int):*
Returns the value of the next property when looping through the collection.
AppSettings
  
parseSettingsFromXml(xml:XML):void
Parses the settings from the given XML instance.
AppSettings
  
setProperty(name:*, value:*):void
Sets a property.
AppSettings
  
xmlLoaderComplete_handler(event:Event):void
Handles the Complete event of the URLLoader instance that loads the XML data with the settings.
AppSettings
Events
 EventSummaryDefined by
   Dispatched when a setting was added.AppSettings
   Dispatched when the AppSettings changes.AppSettings
   Dispatched when the AppSettings is cleared.AppSettings
   Dispatched when a setting was deleted.AppSettings
   Dispatched when the external XML file has been loaded and parsed.AppSettings
Constructor detail
AppSettings()constructor
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
Method detail
addEventListener()method
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)
addListener()method 
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)
AppSettingsInit()method 
protected function AppSettingsInit(enforcer:SingletonEnforcer):void

Initializes the AppSettings instance

Parameters
enforcer:SingletonEnforcer
callProperty()method 
flash_proxy override function callProperty(methodName:*, ... args):*

Catches unknown method calls.

Parameters
methodName:*
 
... args

Returns
*
deleteProperty()method 
flash_proxy override function deleteProperty(name:*):Boolean

Deletes a property.

Parameters
name:*

Returns
Boolean
dispatchEvent()method 
public function dispatchEvent(event:Event):BooleanParameters
event:Event

Returns
Boolean
getInstance()method 
public static function getInstance():AppSettings

Returns the singleton instance of the AppSettings class.

Returns
AppSettings
getProperty()method 
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
*
hasEventListener()method 
public function hasEventListener(type:String):BooleanParameters
type:String

Returns
Boolean
hasProperty()method 
flash_proxy override function hasProperty(name:*):Boolean

Checks if a property exists.

Parameters
name:*

Returns
Boolean
load()method 
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
loadFromFile()method 
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.
nextName()method 
flash_proxy override function nextName(index:int):String

Returns the name of the next property when looping through the collection.

Parameters
index:int

Returns
String
nextNameIndex()method 
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
index:int

Returns
int
nextValue()method 
flash_proxy override function nextValue(index:int):*

Returns the value of the next property when looping through the collection.

Parameters
index:int

Returns
*
parseSettingsFromXml()method 
protected function parseSettingsFromXml(xml:XML):void

Parses the settings from the given XML instance.

Parameters
xml:XML — The XML object that contains the settings.
removeEventListener()method 
public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):voidParameters
type:String
 
listener:Function
 
useCapture:Boolean (default = false)
removeListener()method 
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)
setProperty()method 
flash_proxy override function setProperty(name:*, value:*):void

Sets a property.

Parameters
name:*
 
value:*
willTrigger()method 
public function willTrigger(type:String):BooleanParameters
type:String

Returns
Boolean
xmlLoaderComplete_handler()method 
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:Event
Event detail
AppSettings_Addevent 
Event object type: org.springextensions.actionscript.config.AppSettingsEvent
AppSettingsEvent.type property = org.springextensions.actionscript.config.AppSettingsEvent.ADD

Dispatched when a setting was added.

AppSettings_Changeevent  
Event object type: org.springextensions.actionscript.config.AppSettingsEvent
AppSettingsEvent.type property = org.springextensions.actionscript.config.AppSettingsEvent.CHANGE

Dispatched when the AppSettings changes.

AppSettings_Clearevent  
Event object type: org.springextensions.actionscript.config.AppSettingsEvent
AppSettingsEvent.type property = org.springextensions.actionscript.config.AppSettingsEvent.CLEAR

Dispatched when the AppSettings is cleared.

AppSettings_Deleteevent  
Event object type: org.springextensions.actionscript.config.AppSettingsEvent
AppSettingsEvent.type property = org.springextensions.actionscript.config.AppSettingsEvent.DELETE

Dispatched when a setting was deleted.

AppSettings_Loadevent  
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.