Over 10 years of community discussion and knowledge are maintained here as a read-only archive.
override protected function initializeController( ) : void { super.initializeController(); registerCommand( STARTUP, StartUpCommand ); registerCommand( STAGE_INITIALIZED, StageInitializedCommand ); }
public class StageInitializedCommand extends SimpleCommand{ /** * Register the Proxies. */ override public function execute( note:INotification ) :void { // Register the chainNotifier Mediator and establish chain linkages. var chainNotifier:ChainNotifier = new ChainNotifier(); chainNotifier.AddNode( ApplicationFacade.SPLASH_SHOW, ApplicationFacade.SPLASH_INITIALIZED, note.getBody() ); //include note for startup chainNotifier.AddNode( ApplicationFacade.PROGRESSBAR_SHOW, ApplicationFacade.PROGRESSBAR_INITIALIZED); chainNotifier.AddNode( ApplicationFacade.LOGIN_SHOW, ApplicationFacade.LOGIN_INITIALIZED); facade.registerMediator( chainNotifier ); //onRegister will start first notification }} ///class
override public function handleNotification( note:INotification ):void { var stageVO:StageVO = note.getBody() as StageVO; switch ( note.getName() ) { case ApplicationFacade.STAGE_RESIZED: canvas.setSize(stageVO.screenW, stageVO.screenH); break; case ApplicationFacade.SPLASH_SHOW: //sendNotification will cause chain to next() using canvas as body for next chain link canvas.init(stageVO.screenW, stageVO.screenH, styleProxy.style); this.sendNotification( ApplicationFacade.SPLASH_INITIALIZED, canvas ); break; }}
Main ChainNotifier Constructor the class is conceptually a asynchronous queuing system referred to as a chain transition between nodes (links) is controlled through the use of notifications inthe pureMVC framework You can choose to override the default generated action trigger notifications names if needed, but should not be needed Base action names are appended to the Mediator name to insure unique action names for any givin ChainNotifier in this example , ChainNotifier("MYCHAINNAME"); ... would yeld MYCHAINNAME_ACTION_START, MYCHAINNAME_ACTION_STOP .. etc public function ChainNotifier( qname:String, qstart:String="_ACTION_START", qstop:String="_ACTION_STOP", qcontinue:String="_ACTION_CONTINUE", qend:String="_ACTION_END", qnext:String="_ACTION_NEXT", qprev:String="_ACTION_PREV", qclear:String="_ACTION_CLEAR", qsetactive:String="_ACTION_SETACTIVE" ) :void eg: var chainNotifier:ChainNotifier = new ChainNotifier("MYCHAINNAME"); @param qname - name of chain, If using defaults this name will be added to Action notification names @param qstart - Action start at the beginning of the queue and send first initial notification @param qstop - Action pause at current queue position, receiving of notifications except Actions, will be paused @param qcontinue - Action continue from pause position,activation of notifications will be enabled @param qend - Action skip to end node and send notification @param qnext - tAction node Move to nextAction Node and send notification , default behavior @param qprev - Action node Move back and repeat send notification @param qclear - Action will remove all nodes in array and free memory (no resart from this unless addNode/addAction is used @param qsetactive - experimental,not yet implemented with notifications however, can be triggered as method on the class Active/Inactive will skip Inactive Nodes* Notes: note.Body() and noteType() are sent to next link from prev notifyListener* Start will override all commands (pause, continue)* All Actions can be activated through the use of notifications and notification names overridden at constructor time* onRegister will start first notification, if you addNodes after this you will need to Start()Function addNode This function provides the main method for sequentially adding notifications when its notifyListener notification is recived it moves to the next in the chain. This nex link then emits its notifySender notifications and waits for ITS notifyListener If you wish to use commands, simply register your commands to take the chain links notifySender. when the command is called, at some point, either in the command or what the command is activating will need to send notification for the chain to be moved to next next point. eg. addNode( ApplicationFacade.SPLASH_SHOW, ApplicationFacade.SPLASH_INITIALIZED, note.getBody() ,note.getType()); optional note.getBody() ,note.getType() can be set for the first Node to pass through, to the next node in the chain otherwise body and type are used from the received notifyListener and passed through to the next node in the chain @param notifySender - the notification you wish to send when this link in the chain is triggered @param notifyListener - the notification this link will listen for to move to next link in chain @param body - an optional notification body object to pass ( default is previous links notification body) @param type - and optional notification type string to pass ( default is previous links notification type) @param active - to set a node inactive or active (testing whether this is useful) ( maybe placed before node function in a different release )Function addAction This function provides a method to add Function callbacks triggered by notifications The Class uses this internaly for adding the default Actions Although this is a little outside the box of its intended use it does provide a powerful triggering mechanism from within PureMVC the framework eg. addAction( "MY_ACTION_NOTIFICATION", myFunction); myFunction(node:ChainNotifierNode=null):void //function prototype for any addAction @param notifyListener - the notification this Action will listen for to call nFunction @param nFunction - the function to call when triggered by notifyListener notifications
Can the framework handle dynamic listNotificationInterests ?