Packagecom.yworks.support
Classpublic class Config
InheritanceConfig Inheritance flash.events.EventDispatcher

Configuration mechanism that allows to change the application configuration of a compiled yFiles FLEX application using arbitrary configuration parameters.

Since the config file is loaded asynchronously, config parameters cannot be read before the Event.COMPLETE event has been dispatched.
The configuration file will not be loaded until an event listener for the Event.COMPLETE event type is added.

 
  Example usage:
  
  var cfg:Config = Config.getInstance();
  cfg.configURL = "../../config.xml";
  cfg.addEventListener( Event.COMPLETE, configLoaded );
  
  function configLoaded( evt:Event ):void {
    var portNumber:int = cfg.getInt( "portNumber" );
  }
  
  

Configuration parameters will be parsed from a XML file using the following format:

  
  <config>
    <param1>value1</param1>
    <param2>value2</param2>
    ..
    <paramN>valueN</paramN>
  </config>
  



Public Properties
 PropertyDefined by
  configURL : String
Config
  initialized : Boolean
[read-only] Is true when the configuration file has been parsed.
Config
  ioErrorHandler : Function
[write-only] Set a handler function that will be called when an IOErrorEvent.IO_ERROR is fired when loading the config file.
Config
  securityErrorHandler : Function
[write-only] Set a handler function that will be called when an SecurityErrorEvent.SECURITY_ERROR is fired when loading the config file.
Config
  throwOnError : Boolean
Config
Public Methods
 MethodDefined by
  
This class is a singleton - use getInstance instead.
Config
  
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0.0, useWeakReference:Boolean = false):void
If a listener is added for the Event.COMPLETE event type, this implementation will trigger loading of the config file.
Config
  
getBoolean(key:String):Boolean
Returns the value of a key as Boolean
Config
  
[static]
Config
  
getInt(key:String):int
Returns the value of a key as int
Config
  
getNumber(key:String):Number
Returns the value of a key as Number
Config
  
getProperty(key:String):String
Returns the value of a key as String
Config
  
getUint(key:String):uint
Returns the value of a key as uint
Config
Events
 EventSummaryDefined by
   Dispatched when the configuration file has been parsed.Config
   Dispatched when the configuration file could not be loaded.Config
Property detail
configURLproperty
configURL:String  [read-write]Implementation
    public function get configURL():String
    public function set configURL(value:String):void
initializedproperty 
initialized:Boolean  [read-only]

Is true when the configuration file has been parsed.

Implementation
    public function get initialized():Boolean
ioErrorHandlerproperty 
ioErrorHandler:Function  [write-only]

Set a handler function that will be called when an IOErrorEvent.IO_ERROR is fired when loading the config file.

The default value is null.

Implementation
    public function set ioErrorHandler(value:Function):void
securityErrorHandlerproperty 
securityErrorHandler:Function  [write-only]

Set a handler function that will be called when an SecurityErrorEvent.SECURITY_ERROR is fired when loading the config file.

The default value is null.

Implementation
    public function set securityErrorHandler(value:Function):void
throwOnErrorproperty 
throwOnError:Boolean  [read-write]Implementation
    public function get throwOnError():Boolean
    public function set throwOnError(value:Boolean):void
Constructor detail
Config()constructor
public function Config()

This class is a singleton - use getInstance instead.


Throws
Method detail
addEventListener()method
public override function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0.0, useWeakReference:Boolean = false):void

If a listener is added for the Event.COMPLETE event type, this implementation will trigger loading of the config file.

Parameters
type:String
 
listener:Function
 
useCapture:Boolean (default = false)
 
priority:int (default = 0.0)
 
useWeakReference:Boolean (default = false)
getBoolean()method 
public function getBoolean(key:String):Boolean

Returns the value of a key as Boolean

Parameters
key:String

Returns
Boolean — The boolean value of the configuration parameter key.
getInstance()method 
public static function getInstance():Config

Returns
Config — The shared instance of the configuration class.
getInt()method 
public function getInt(key:String):int

Returns the value of a key as int

Parameters
key:String

Returns
int — The int value of the configuration parameter key.
getNumber()method 
public function getNumber(key:String):Number

Returns the value of a key as Number

Parameters
key:String

Returns
Number — The Number value of the configuration parameter key.
getProperty()method 
public function getProperty(key:String):String

Returns the value of a key as String

Parameters
key:String

Returns
String — The string value of the configuration parameter key.
getUint()method 
public function getUint(key:String):uint

Returns the value of a key as uint

Parameters
key:String

Returns
uint — The uint value of the configuration parameter key.
Event detail
completeevent 
Event object type: flash.events.Event

Dispatched when the configuration file has been parsed.

ioErrorevent  
Event object type: flash.events.IOErrorEvent

Dispatched when the configuration file could not be loaded.