Packagecom.bourre.ioc.load.runtime
Classpublic class RuntimeContextLoader
InheritanceRuntimeContextLoader Inheritance ApplicationLoader Inheritance AbstractLoader

Player version: Flash Player 9.0
Language version: ActionScript 3.0

The RuntimeContextLoader class allow to load external xml context at runtime.

All loaded objects ( dll, resources, display tree ) are injected into global IoC context.


Example
  
  var rtLoader : RuntimeContextLoader = new RuntimeContextLoader(  );
  rtLoader.addEventListener( ApplicationLoaderEvent.onApplicationInitEVENT, _onComplete );
  rtLoader.load( new URLRequest( "config/runtimeContext.xml" ) );
  

View the examples.



Public Properties
 PropertyDefined by
 InheritedDEBUG_LOADING_ENABLED : Boolean = false
[static] Enabled or not the debugging feature during application loading.
ApplicationLoader
 InheritedDEFAULT_CONFIG_PATH : String = ""
[static] Default path for applicationContext file.
ApplicationLoader
 InheritedDEFAULT_CONTEXT_FILE : String = ""
[static] Default URL for applicationContext file.
ApplicationLoader
 InheritedDEFAULT_DLL_PATH : String = ""
[static] Default path for dll files.
ApplicationLoader
 InheritedDEFAULT_GFX_PATH : String = ""
[static] Default path for gfx ( display tree ) files.
ApplicationLoader
 InheritedDEFAULT_RSC_PATH : String = ""
[static] Default path for resources files.
ApplicationLoader
 InheritedRELATIVE_PATH : String = "#//"
[static] Defines wildcard to search to identify a forced relative path.
ApplicationLoader
  sandbox : Boolean
Defines if context links ( url ) are relative to the loaded xml context file.
RuntimeContextLoader
Protected Properties
 PropertyDefined by
 Inherited_sPrefixURL : String
AbstractLoader
 Inherited_sURL : String
AbstractLoader
Public Methods
 MethodDefined by
  
RuntimeContextLoader(container:DisplayObjectContainer = null)
Creates new RuntimeContextLoader instance.
RuntimeContextLoader
 Inherited
Adds the passed-in listener as listener for all events dispatched by loader.
ApplicationLoader
 Inherited
addASyncCommandListener(listener:ASyncCommandListener, ... rest):Boolean
Adds the passed-in command listener object as listener for this command events.
AbstractLoader
 Inherited
addEventListener(type:String, listener:Object, ... rest):Boolean
Adds an event listener for the specified event type.
AbstractLoader
 Inherited
addListener(listener:LoaderListener):Boolean
Adds the passed-in listener as listener for all events dispatched by this event broadcaster.
AbstractLoader
 Inherited
addProcessingMethod(processingMethod:Function, ... args):void
Adds new preprocessing method.
ApplicationLoader
 Inherited
Adds new pre processing processor.
ApplicationLoader
 Inherited
execute(e:Event = null):void
Execute the request according to the current command data.
AbstractLoader
 Inherited
Fires the onCommandEnd event to the listeners of this command.
AbstractLoader
 Inherited
Broadcasts ApplicationLoaderEvent.onApplicationInitEVENT event type when application is ready.
ApplicationLoader
 Inherited
Broadcasts ApplicationLoaderEvent.onApplicationParsedEVENT event type when xml is parsed.
ApplicationLoader
 Inherited
Broadcasts ApplicationLoaderEvent.onApplicationStartEVENT event type when xml is parsed.
ApplicationLoader
 Inherited
fireOnApplicationState(state:String):void
Broadcasts ApplicationLoaderEvent.onApplicationStateEVENT when IOC engine processing change his state ( DLL, Resources, GFX, etc.
ApplicationLoader
 Inherited
Broadcasts ApplicationLoaderEvent.onApplicationChannelsAssignedEVENT event type when all plugin channels are initialized.
ApplicationLoader
 Inherited
fireOnLoadErrorEvent(message:String = ""):void
Dispatches event when an error occur.
AbstractLoader
 Inherited
Dispatches event when the loading is finished.
AbstractLoader
 Inherited
Dispatches event during loading progression.
AbstractLoader
 Inherited
Dispatches event when the loading starts.
AbstractLoader
 Inherited
AbstractLoader
 Inherited
Broadcasts ApplicationLoaderEvent.onApplicationMethodsCalledEVENT event type when all method-call are executed.
ApplicationLoader
 Inherited
Broadcasts ApplicationLoaderEvent.onApplicationObjectsBuiltEVENT event type when all elements in xml are built.
ApplicationLoader
 Inherited
Returns ApplicationAssembler used in by this loader.
ApplicationLoader
 Inherited
Returns the number of bytes loaded.
AbstractLoader
 Inherited
Returns the total number of bytes to load.
AbstractLoader
 Inherited
getContent():Object
Returns loaded content.
AbstractLoader
  
getContextURL(filename:String):URLRequest
[static] Returns URLRequest using internal IoC url manager.
RuntimeContextLoader
 Inherited
Returns the DisplayObjectBuilder used by this loader to load and build all context elements.
ApplicationLoader
 Inherited
getName():String
Returns the loader identifier.
AbstractLoader
 Inherited
Returns parser collection used by assembler.
ApplicationLoader
 Inherited
getPerCent():Number
Returns a percentage of bytes loaded and total bytes to load.
AbstractLoader
 Inherited
Returns loading strategy used by the loader.
AbstractLoader
 Inherited
getTimeOut():Number
Returns the loading timeout limit
AbstractLoader
 Inherited
getURL():URLRequest
Returns the URL used by this loader.
AbstractLoader
 Inherited
getURLRequest(request:URLRequest, prefix:String = ""):URLRequest
[static] Returns clean URL address using passed-in base url and optional prefix one.
ApplicationLoader
  
hasContainer():Boolean
Returns true if a container target is defined for loaded display tree.
RuntimeContextLoader
 Inherited
isAntiCache():Boolean
Returns true if 'anticache' system is on.
AbstractLoader
 Inherited
isLoaded():Boolean
Returns true if all bytes are loaded.
AbstractLoader
 Inherited
isRunning():Boolean
Returns true if this object is running.
AbstractLoader
 Inherited
load(url:URLRequest = null, context:LoaderContext = null):void
Starts loading.
ApplicationLoader
 Inherited
Triggered when a display object is built.
ApplicationLoader
 Inherited
Triggered when a display loader is registred.
ApplicationLoader
 Inherited
All files in xml context are loaded.
ApplicationLoader
 Inherited
Triggered when context files starts processing.
ApplicationLoader
 Inherited
Triggered when a graphic file loading is finished.
ApplicationLoader
 Inherited
Triggered when a graphic file starts loading.
ApplicationLoader
 Inherited
Triggered when a DLL file loading is finished.
ApplicationLoader
 Inherited
Triggered when a DLL file starts loading.
ApplicationLoader
 Inherited
ApplicationLoader
 Inherited
ApplicationLoader
 Inherited
ApplicationLoader
 Inherited
ApplicationLoader
 Inherited
ApplicationLoader
 Inherited
Preprocessing is completed.
ApplicationLoader
 Inherited
Triggered when a resource file loading is finished.
ApplicationLoader
 Inherited
Triggered when a resource file starts loading.
ApplicationLoader
  
parseContext(xml:*):void
RuntimeContextLoader
 Inherited
prefixURL(sURL:String):void
Adds prefix to URL passed to the loader instance.
AbstractLoader
  
processParsing(xml:*):void
Parses the xml context.
RuntimeContextLoader
 Inherited
release():void
Releases instance and all registered listeners.
AbstractLoader
 Inherited
Removes the passed-in listener object from loader.
ApplicationLoader
 Inherited
Removes the passed-in command listener object as listener for this command events.
AbstractLoader
 Inherited
removeEventListener(type:String, listener:Object):Boolean
Removes the passed-in listener for listening the specified event.
AbstractLoader
 Inherited
removeListener(listener:LoaderListener):Boolean
Removes the passed-in listener object from this event broadcaster.
AbstractLoader
 Inherited
run():void
Starts the asynchronous process of this runnable object.
AbstractLoader
 Inherited
runPreprocessor(xml:*):void
Starts IoC pre processing.
ApplicationLoader
 Inherited
setAntiCache(b:Boolean):void
Sets the 'anticache' system to true to add timestamp value to the loaded URL.
AbstractLoader
 Inherited
Sets the ApplicationAssembler to use by this loader.
ApplicationLoader
 Inherited
setContent(content:Object):void
Uses to replace this loader content.
AbstractLoader
 Inherited
setDisplayObjectBuilder(displayObjectBuilder:DisplayObjectBuilder):void
Sets the DisplayObjectBuilder to use by this loader to load and build all context elements.
ApplicationLoader
 Inherited
setName(sName:String):void
Sets the loader identifier.
AbstractLoader
 Inherited
Sets the parsers collection to use in order to build context.
ApplicationLoader
 Inherited
setTimeOut(n:Number):void
Sets a loading timeout limit.
AbstractLoader
  
setURL(request:URLRequest):void
Defined from which the URL will be loaded.
RuntimeContextLoader
 Inherited
setVariable(name:String, value:Object):void
Sets new pair name / value for variable replacement when context file will be laoded.
ApplicationLoader
Protected Methods
 MethodDefined by
 Inherited
ApplicationLoader
 Inherited
ApplicationLoader
 Inherited
ApplicationLoader
 Inherited
fireEvent(e:Event):void
Dispatched passed-in event to all registered listeners.
AbstractLoader
 Inherited
fireEventType(type:String, errorMessage:String = ""):void
Dispatches event using passed-in type and optional error message.
AbstractLoader
  
getContainer(container:DisplayObjectContainer = null):DisplayObjectContainer
Retreives correct container for loaded display tree.
RuntimeContextLoader
 Inherited
getLoaderEvent(type:String, errorMessage:String = ""):LoaderEvent
ApplicationLoader
 Inherited
initContext():void
ApplicationLoader
 Inherited
initQueryURL():void
Retreives Query URL.
ApplicationLoader
 Inherited
onInitialize():void
AbstractLoader
 Inherited
preprocess(xml:XML):XML
Do preprocessing actions on xml context before parsing.
ApplicationLoader
 Inherited
setListenerType(type:Class):void
Defines the type of listeners this event broadcaster support.
AbstractLoader
Events
 EventSummaryDefined by
 Inherited Dispatched when all communication channels are assigned.ApplicationLoader
 Inherited Dispatched when application is ready.
IoC engine complete.
ApplicationLoader
 Inherited Dispatched when all methods defined in context are called.ApplicationLoader
 Inherited Dispatched when all context objects are built.ApplicationLoader
 Inherited Dispatched when context file is parsed.ApplicationLoader
 Inherited Dispatched when context files loading starts.ApplicationLoader
 Inherited Dispatched when IoC engien state change Possible values for state are :
  • ApplicationLoaderEvent.LOAD_STATE
  • ApplicationLoaderEvent.PREPROCESS_STATE
  • ApplicationLoaderEvent.PARSE_STATE
  • ApplicationLoaderEvent.DLL_STATE
  • ApplicationLoaderEvent.RSC_STATE
  • ApplicationLoaderEvent.GFX_STATE
  • ApplicationLoaderEvent.BUILD_STATE
  • ApplicationLoaderEvent.RUN_STATE
.
ApplicationLoader
 Inherited ispatched when an error occurs during context item file loading.ApplicationLoader
 Inherited Dispatched when an error occurs during loading.AbstractLoader
 Inherited Dispatched when a context item file loading is finished ApplicationLoader
 Inherited Dispatched when loading is finished.AbstractLoader
 Inherited Dispatched during context item file loading progression ApplicationLoader
 Inherited Dispatched during loading progression.AbstractLoader
 Inherited Dispatched when a context item file starts loading.ApplicationLoader
 Inherited Dispatched when loader starts loading.AbstractLoader
 Inherited Dispatched when a timeout occurs during context item file loading.ApplicationLoader
 Inherited Dispatched when a timeout occurs during loading.AbstractLoader
Public Constants
 ConstantDefined by
 InheritedABSOLUTE_PATH : String = "://"
[static] Defines wildcard to search to identify an absolute path.
ApplicationLoader
 InheritedDEFAULT_URL : URLRequest
[static] Default URL Request for applicationContext file.
ApplicationLoader
Property detail
sandboxproperty
sandbox:Boolean  [read-write]

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Defines if context links ( url ) are relative to the loaded xml context file.

If true, all urls must be relative to the loaded xml context file url.

The default value is false.

Implementation
    public function get sandbox():Boolean
    public function set sandbox(value:Boolean):void
Constructor detail
RuntimeContextLoader()constructor
public function RuntimeContextLoader(container:DisplayObjectContainer = null)

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Creates new RuntimeContextLoader instance.

Parameters
container:DisplayObjectContainer (default = null) — Container for loaded display tree
Method detail
getContainer()method
protected function getContainer(container:DisplayObjectContainer = null):DisplayObjectContainer

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Retreives correct container for loaded display tree.

Parameters
container:DisplayObjectContainer (default = null)

Returns
DisplayObjectContainer
getContextURL()method 
public static function getContextURL(filename:String):URLRequest

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns URLRequest using internal IoC url manager.

Parameters
filename:String

Returns
URLRequest — The URLRequest using internal IoC url manager.
hasContainer()method 
public function hasContainer():Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns true if a container target is defined for loaded display tree.

Returns
Booleantrue if a container target is defined for loaded display tree.
parseContext()method 
public override function parseContext(xml:*):void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Parameters
xml:*
processParsing()method 
public override function processParsing(xml:*):void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Parses the xml context.

Include files are loaded and preprocessing is done.

Parameters
xml:*
setURL()method 
public override function setURL(request:URLRequest):void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Defined from which the URL will be loaded.

Parameters
request:URLRequest — URL to load
Examples
XML context definition (runtime.xml)
<beans>
    <dll url="MonitoringPluginDLL" />
    
    <root id="local">
        <logo id="logo" url="assets/logo.jpg" visible="true" />
    </root>
    
    <plugin id="monitor" type="lowra.plugins.utils.MonitoringPlugin">
        <property name="x" value="100" />
        <property name="y" value="0" />
    </plugin>
</beans>

Loads complete context
package com.bourre.ioc.load.runtime 
{
    import com.bourre.ioc.bean.BeanFactory;
    import com.bourre.ioc.context.processor.ProcessingHelper;
    import com.bourre.ioc.load.ApplicationLoaderEvent;
    import com.bourre.ioc.parser.ContextNodeNameList;
    import com.bourre.load.LoaderEvent;
    import com.bourre.log.PixlibDebug;
    
    import flash.display.DisplayObject;
    import flash.display.DisplayObjectContainer;
    import flash.net.URLRequest;        

    public class RuntimeContextLoaderSample 
    {
        public function RuntimeContextLoaderSample()
        {
            var node : XML = <object id='obj2' type='Object'><property name='p4' value='hello4' /></object>;
            
            var target : DisplayObjectContainer = BeanFactory.getInstance().locate( ContextNodeNameList.ROOT ) as DisplayObjectContainer;
            
            var loader : RuntimeContextLoader = new RuntimeContextLoader( target );
            loader.sandbox = true;
            loader.addEventListener( ApplicationLoaderEvent.onApplicationInitEVENT, onLoadContext );
            
            loader.addProcessingMethod( ProcessingHelper.changeObjectAttribute, "logo", "visible", "false" );
            loader.addProcessingMethod( ProcessingHelper.changePropertyValue, "monitor", "x", 200 );
            loader.addProcessingMethod( ProcessingHelper.changePropertyValue, "monitor", "y", 200 );
            loader.addProcessingMethod( ProcessingHelper.addResource, "newStyle", "myStyle.css" );
            loader.addProcessingMethod( ProcessingHelper.addNode, node );
            
            loader.load( new URLRequest ( "runtime.xml" ) );
        }
        
        public function onLoadContext( e : LoaderEvent ) : void
        {
            PixlibDebug.INFO( "Context loaded : " + e.getLoader().getURL().url );
            
            var mc : DisplayObject = BeanFactory.getInstance().locate( "logo" ) as DisplayObject;
            mc.alpha = 0.5;
        }
    }
}