Packageorg.mymvc
Classpublic class MyMVCController

This is a controller class. It provides Event-Command mapping and flow switching. In practice, the only functions developers should care are addCommand, addParallelCommands and addEventListener. Use addCommand to add a single or sequence of commands. e.g. addCommand('LOGIN', LoginCommand) or addCommand('LOGIN', [LoginCommand,DisplayResultCommand])



Protected Properties
 PropertyDefined by
  commands : Dictionary
Dictionary of event name to command class mappings
MyMVCController
Public Methods
 MethodDefined by
  
addCommand(eventType:String, commandRef:Object, useWeakReference:Boolean = true):void
Registers a MyMVCCommand class, or a sequence MyMVCCommands, with the Front Controller, against an event name and listens for events with that name.
MyMVCController
  
addParallelCommands(eventType:String, commandRef:Object, useWeakReference:Boolean = true):void
Registers a parallel of MyMVCCommand classes with the Front Controller, against an event name and listens for events with that name.
MyMVCController
  
removeCommand(eventType:String):void
Deregisters a MyMVCCommand class (or a class array) with the given event name from the Front Controller.
MyMVCController
Protected Methods
 MethodDefined by
  
addEventListener(eventType:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
A front controller can listen to an event emitted by MyMVCRadioStation
MyMVCController
  
dispatchEvent(event:MyMVCEvent):Boolean
A front controller can dispatch event to MyMVCRadioStation
MyMVCController
  
Executes the single command
MyMVCController
  
Executes the commands (sequence command)
MyMVCController
  
executeNext(e:MyMVCEvent, tmpSequenceCommandIndex:int, internalData:*):void
Executes the next command in a sequence command.
MyMVCController
  
Executes the parallel commands
MyMVCController
  
getCommand(commandName:String):Class
Returns the command class registered with the command name.
MyMVCController
  
getCommands(commandName:String):Array
Returns the array of command classes registered with the command name.
MyMVCController
Property detail
commandsproperty
protected var commands:Dictionary

Dictionary of event name to command class mappings

Method detail
addCommand()method
public function addCommand(eventType:String, commandRef:Object, useWeakReference:Boolean = true):void

Registers a MyMVCCommand class, or a sequence MyMVCCommands, with the Front Controller, against an event name and listens for events with that name.

When an event is broadcast that matches eventType, the MyMVCCommand class referred to by commandRef receives control of the application, by having its execute() method invoked.

If the registered command are a sequence of command, when an event is broadcast that matches eventType, the MyMVCCommand classes referred to by commandRef will execute in sequence (i.e., one will execute after the previous one completes. Parameters

eventType:String — The name of the event that will be broadcast by the when a particular user gesture occurs, eg "LOGIN"
 
commandRef:Object — A MyMVCCommand Class reference upon which execute() can be called when the Front Controller hears an event broadcast with eventType. Typically, this argument is passed as "LoginCommand" or similar. Or, it can be an array
 
useWeakReference:Boolean (default = true) — A Boolean indicating whether the controller should added as a weak reference to the MyMVCRadioStation, meaning it will eligibile for garbage collection if it is unloaded from the main application.
addEventListener()method 
protected function addEventListener(eventType:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void

A front controller can listen to an event emitted by MyMVCRadioStation

Parameters
eventType:String
 
listener:Function
 
useCapture:Boolean (default = false)
 
priority:int (default = 0)
 
useWeakReference:Boolean (default = false)
addParallelCommands()method 
public function addParallelCommands(eventType:String, commandRef:Object, useWeakReference:Boolean = true):void

Registers a parallel of MyMVCCommand classes with the Front Controller, against an event name and listens for events with that name.

When an event is broadcast that matches eventType, the front controller will split the event data (which has to be an array) into pieces. For each element of the data, the MyMVCCommand classes referred to by commandRef will execute in sequence (i.e., one will execute after the previous one completes). After one element of the data is processed, then this sequence of commands will process the next data. Parameters

eventType:String — The name of the event that will be broadcast by the when a particular user gesture occurs. e.g. "LOGIN"
 
commandRef:Object — An Array of MyMVCCommand Class reference. e.g. [LoginCommand,DisplayResultCommand]
 
useWeakReference:Boolean (default = true)
dispatchEvent()method 
protected function dispatchEvent(event:MyMVCEvent):Boolean

A front controller can dispatch event to MyMVCRadioStation

Parameters
event:MyMVCEvent

Returns
Boolean
executeCommand()method 
protected function executeCommand(event:MyMVCEvent):void

Executes the single command

Parameters
event:MyMVCEvent
executeCommands()method 
protected function executeCommands(event:MyMVCEvent):void

Executes the commands (sequence command)

Parameters
event:MyMVCEvent
executeNext()method 
protected function executeNext(e:MyMVCEvent, tmpSequenceCommandIndex:int, internalData:*):void

Executes the next command in a sequence command. Dispatch MyMVCEvent.COMPLETE event when all commands are finish.

Parameters
e:MyMVCEvent
 
tmpSequenceCommandIndex:int
 
internalData:*
executeParallelCommands()method 
protected function executeParallelCommands(event:MyMVCEvent):void

Executes the parallel commands

Parameters
event:MyMVCEvent
getCommand()method 
protected function getCommand(commandName:String):Class

Returns the command class registered with the command name.

Parameters
commandName:String

Returns
Class
getCommands()method 
protected function getCommands(commandName:String):Array

Returns the array of command classes registered with the command name.

Parameters
commandName:String

Returns
Array
removeCommand()method 
public function removeCommand(eventType:String):void

Deregisters a MyMVCCommand class (or a class array) with the given event name from the Front Controller. This method can be used to deregister a single command or a sequence command.

Parameters
eventType:String — The name of the event