<commit_before>RobotLegs AS3
=============

RobotLegs AS3 is an event driven MVCS micro-architecture for Flash and Flex applications. It is inspired by the excellent PureMVC framework, but uses Dependency Injection to do away with Singletons, Services Locators and Casting, and provides automatic Mediator registration for View Components.

Currently, RobotLegs makes use of SmartyPantsIOC - an AS3 Dependency Injection framework for Flash and Flex.

No casting! No fetching! No Singletons! You can read more about it on my [blog](http://shaun.boyblack.co.za/blog/robotlegs-as3/).

Installation
------------

**Flex/FlashBuilder:**

Drop RobotLegsLib.swc and SmartyPantsIOC.swc into your "libs" folder.

If you are building a plain ActionScript project you might need to create the "libs" folder manually:

Right click the project, and create a New Folder called "libs".
Right click the project, open "properties", "Flex Build Path", "Library path", and add the folder "libs".

**Other IDEs or Editors:**

Include RobotLegsLib.swc and SmartyPantsIOC.swc in your build path.

Terminology
-----------

RobotLegs AS3 uses the same terminology as PureMVC for many of it's components and concepts, such as:

Mediators, View Components, Proxies and Commands

Collectively, these are referred to as Framework or Context Actors.

RobotLegs does not, however, employ the use of the Facade design pattern or PureMVC's Notification scheme. Instead, RobotLegs uses:

Contexts and Events

Usage
-----

**Facade/Context**

RobotLegs does not make use of the Facade design pattern - instead there is something known as a Context. It's not really the same thing, and is only used to bootstrap your application, and to hold references to shared Context actors.

Typically, when starting a new project, you extend the default Context, provide Dependency Injection and Reflection adapters, and override the startup() method.

Inside the startup() method you bind a couple of Commands to a startup event and then dispatch that event.

    public class HelloFlexContext extends Context
    {
      public function HelloFlexContext( contextView:DisplayObjectContainer )
      {
        super( contextView, new SmartyPantsInjector(), new SmartyPantsReflector() );
      }
      
      override public function startup():void
      {
        commandFactory.mapCommand( ContextEvent.STARTUP, PrepModelCommand, true );
        commandFactory.mapCommand( ContextEvent.STARTUP, PrepControllerCommand, true );
        commandFactory.mapCommand( ContextEvent.STARTUP, PrepServicesCommand, true );
        commandFactory.mapCommand( ContextEvent.STARTUP, PrepViewCommand, true );
        commandFactory.mapCommand( ContextEvent.STARTUP, StartupCommand, true );
        eventBroadcaster.dispatchEvent( new ContextEvent( ContextEvent.STARTUP ) );
      }
    }

Instantiate the Context and pass it a reference to your view. For a Flex application it might look like this:

    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="onCC()">
    	<mx:Script>
    		<![CDATA[
    			import net.boyblack.robotlegs.demos.helloflex.HelloFlexContext;
    			private var helloContext:HelloFlexContext;
          
    			private function onCC():void
    			{
    				helloContext = new HelloFlexContext( this );
    			}
    		]]>
    	</mx:Script>
    </mx:Application>

If you are building a plain ActionScript application, your root Sprite (entry point) might look like this:

    package
    {
    	import flash.display.Sprite;
    	import net.boyblack.robotlegs.demos.hello.HelloContext;
      
    	public class HelloActionScript extends Sprite
    	{
    		private var context:HelloContext;
		    
    		public function HelloActionScript()
    		{
    			context = new HelloContext( this );
    		}
    	}
    }

By default, a Context will automatically execute it's startup() method when it's View Component is added to the Stage.

**Commands**

RobotLegs make use of native Flash Player events for framework communication. Much like PureMVC, Commands can be bound to events.

No parameters are passed to a Command's execute method however. Instead, you define the concrete event that will be passed to the Command as a dependency. This relieves you from having to cast the event.

Multiple Commands can be bound to an event type. They will be executed in the order that they were mapped. This is very handy for mapping your startup commands.

To get a reference to the concrete event that triggered a Command, you must declare the event as a Dependency:

    public class TryClearMessages extends Command
    {
    	[Inject]
    	public var event:SystemEvent;<commit_msg>README edits<commit_after>RobotLegs AS3
=============

RobotLegs AS3 is an event driven MVCS micro-architecture for Flash and Flex applications. It is inspired by the excellent PureMVC framework, but uses Dependency Injection to do away with Singletons, Services Locators and Casting, and provides automatic Mediator registration for View Components.

Currently, RobotLegs makes use of SmartyPantsIOC - an AS3 Dependency Injection framework for Flash and Flex.

No casting! No fetching! No Singletons! You can read more about it on my [blog](http://shaun.boyblack.co.za/blog/robotlegs-as3/).

Installation
------------

**Flex/FlashBuilder:**

Drop RobotLegsLib.swc and SmartyPantsIOC.swc into your "libs" folder.

If you are building a plain ActionScript project you might need to create the "libs" folder manually:

Right click the project, and create a New Folder called "libs".
Right click the project, open "properties", "Flex Build Path", "Library path", and add the folder "libs".

**Other IDEs or Editors:**

Include RobotLegsLib.swc and SmartyPantsIOC.swc in your build path.

Terminology
-----------

RobotLegs AS3 uses the same terminology as PureMVC for many of it's components and concepts, such as:

Mediators, View Components, Proxies and Commands

Collectively, these are referred to as Framework or Context Actors.

RobotLegs does not, however, employ the use of the Facade design pattern or PureMVC's Notification scheme. Instead, RobotLegs uses:

Contexts and Events

Usage
-----

**Facade/Context**

RobotLegs does not make use of the Facade design pattern - instead there is something known as a Context. It's not really the same thing, and is only used to bootstrap your application, and to hold references to shared Context actors.

Typically, when starting a new project, you extend the default Context, provide Dependency Injection and Reflection adapters, and override the startup() method.

Inside the startup() method you bind a couple of Commands to a startup event and then dispatch that event.

    public class HelloFlexContext extends Context
    {
    	public function HelloFlexContext( contextView:DisplayObjectContainer )
    	{
    		super( contextView, new SpringInjector(), new SpringReflector() );
    	}
    	
    	override public function startup():void
    	{
    		commandFactory.mapCommand( ContextEvent.STARTUP, PrepModelCommand, true );
    		commandFactory.mapCommand( ContextEvent.STARTUP, PrepControllerCommand, true );
    		commandFactory.mapCommand( ContextEvent.STARTUP, PrepServicesCommand, true );
    		commandFactory.mapCommand( ContextEvent.STARTUP, PrepViewCommand, true );
    		commandFactory.mapCommand( ContextEvent.STARTUP, StartupCommand, true );
    		eventBroadcaster.dispatchEvent( new ContextEvent( ContextEvent.STARTUP ) );
    	}
    }
	

Instantiate the Context and pass it a reference to your view. For a Flex application it might look like this:

    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" preinitialize="onPreInitialize()">
    	<mx:Script>
    		<![CDATA[
    			import net.boyblack.robotlegs.demos.helloflex.HelloFlexContext;
    			
    			private var context:HelloFlexContext;
    			
    			private function onPreInitialize():void
    			{
    				context = new HelloFlexContext( this );
    			}
    		]]>
    	</mx:Script>
    </mx:Application>

If you are building a plain ActionScript application, your root Sprite (entry point) might look like this:

    package
    {
    	import flash.display.Sprite;
    	import net.boyblack.robotlegs.demos.hello.HelloContext;
    	
    	public class HelloActionScript extends Sprite
    	{
    		private var context:HelloContext;
			
    		public function HelloActionScript()
    		{
    			context = new HelloContext( this );
    		}
    	}
    }

By default, a Context will automatically execute it's startup() method when it's View Component is added to the Stage.

**Commands**

RobotLegs make use of native Flash Player events for framework communication. Much like PureMVC, Commands can be bound to events.

No parameters are passed to a Command's execute method however. Instead, you define the concrete event that will be passed to the Command as a dependency. This relieves you from having to cast the event.

Multiple Commands can be bound to an event type. They will be executed in the order that they were mapped. This is very handy for mapping your startup commands.

To get a reference to the concrete event that triggered a Command, you must declare the event as a Dependency:

    public class TryClearMessages extends Command
    {
    	[Inject]
    	public var event:SystemEvent;
{'fraction_non_alphanumeric': 0.06838709677419355, 'fraction_numerical': 0.001935483870967742, 'mean_word_length': 3.7117527862208712, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5782196', 'n_tokens_mistral': 2619, 'n_tokens_neox': 2483, 'n_words': 1062}