| Package | com.yworks.support |
| Class | public class Config |
| Inheritance | Config flash.events.EventDispatcher |
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>
| Property | Defined 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 | ||
| Method | Defined by | ||
|---|---|---|---|
|
Config()
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 | ||
| Event | Summary | Defined by | ||
|---|---|---|---|---|
| Dispatched when the configuration file has been parsed. | Config | |||
| Dispatched when the configuration file could not be loaded. | Config | |||
| configURL | property |
configURL:String [read-write]Implementation
public function get configURL():String
public function set configURL(value:String):void
| initialized | property |
initialized:Boolean [read-only]
Is true when the configuration file has been parsed.
public function get initialized():Boolean
| ioErrorHandler | property |
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.
public function set ioErrorHandler(value:Function):void
| securityErrorHandler | property |
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.
public function set securityErrorHandler(value:Function):void
| throwOnError | property |
throwOnError:Boolean [read-write]Implementation
public function get throwOnError():Boolean
public function set throwOnError(value:Boolean):void
| Config | () | constructor |
public function Config()
This class is a singleton - use getInstance instead.
— |
| 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.
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
key:String |
Boolean — The boolean value of the configuration parameter key.
|
| getInstance | () | method |
public static function getInstance():ConfigReturns
Config —
The shared instance of the configuration class.
|
| getInt | () | method |
public function getInt(key:String):int
Returns the value of a key as int
key:String |
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
key:String |
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
key:String |
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
key:String |
uint — The uint value of the configuration parameter key.
|
| complete | event |
| ioError | event |
flash.events.IOErrorEvent
Dispatched when the configuration file could not be loaded.