Created
June 28, 2012 08:30
-
-
Save nowri/3009915 to your computer and use it in GitHub Desktop.
Robotlegs robotlegs-utilities-Modular sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// -------------------------------------------------------------------------- | |
// | |
// | |
// @author : nowri.ka | |
// @date : 2012/05/29 | |
// | |
// -------------------------------------------------------------------------- | |
package | |
{ | |
public class ChildView extends Sprite implements IModule | |
{ | |
// -------------------------------------------------------------------------- | |
// | |
// Constructor | |
// | |
// -------------------------------------------------------------------------- | |
public function ChildView() | |
{ | |
addEventListener(Event.ADDED_TO_STAGE, addToStageHandler); | |
} | |
// -------------------------------------------------------------------------- | |
// | |
// Variables | |
// | |
// -------------------------------------------------------------------------- | |
protected var context:IModuleContext; | |
// -------------------------------------------------------------------------- | |
// | |
// Methods | |
// | |
// -------------------------------------------------------------------------- | |
// ---------------------------------- | |
// Robotlegs frameWork methods | |
// ---------------------------------- | |
/** | |
* We need to initialize our context by setting the parent | |
* injector for the module. This is actually injected by the | |
* shell, so no need to worry about it! | |
*/ | |
[Inject] | |
public function set parentInjector(value:IInjector):void | |
{ | |
context = new ChildContext(this, true, value); | |
} | |
public function dispose():void | |
{ | |
} | |
// -------------------------------------------------------------------------- | |
// | |
// Event Handler | |
// | |
// -------------------------------------------------------------------------- | |
private function addToStageHandler(e:Event):void | |
{ | |
removeEventListener(Event.ADDED_TO_STAGE, addToStageHandler); | |
if(!context) | |
{ | |
context = new ChildContext(this); | |
} | |
} | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package | |
{ | |
import flash.display.DisplayObjectContainer; | |
import flash.system.ApplicationDomain; | |
import org.robotlegs.base.ContextEvent; | |
import org.robotlegs.core.IInjector; | |
import org.robotlegs.utilities.modular.mvcs.ModuleContext; | |
public class ParentContext extends ModuleContext | |
{ | |
public function ParentContext(contextView:DisplayObjectContainer=null, autoStartup:Boolean=true, parentInjector:IInjector=null, applicationDomain:ApplicationDomain=null) | |
{ | |
super(contextView, autoStartup, parentInjector, applicationDomain); | |
} | |
override public function startup():void | |
{ | |
// module | |
viewMap.mapType(ChildView); | |
moduleCommandMap.mapEvent(ParentContextDispatchEvent.DISPATCH, ParentContextDispatchCommand, ParentContextDispatchEvent); | |
//view | |
mediatorMap.mapView(ParentView, ParentViewMediator); | |
super.startup(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment