Package org.puremvc.as3.core
Class public class Controller
Implements IController
A Singleton IController implementation.

In PureMVC, the Controller class follows the 'Command and Controller' strategy, and assumes these responsibilities:

Your application must register ICommands with the Controller.

The simplest way is to subclass Facade, and use its initializeController method to add your registrations.

See also

View
Observer
Notification
SimpleCommand
MacroCommand


Protected Properties
  Property Defined by
    commandMap : Array
Controller
    instance : IController
[static]
Controller
    view : IView
Controller

Public Methods
  Method Defined by
   
Constructor.
Controller
   
If an ICommand has previously been registered to handle a the given INotification, then it is executed.
Controller
   
[static] Controller Singleton Factory method.
Controller
   
hasCommand(notificationName:String):Boolean
Check if a Command is registered for a given Notification
Controller
   
registerCommand(notificationName:String, commandClassRef:Class):void
Register a particular ICommand class as the handler for a particular INotification.
Controller
   
removeCommand(notificationName:String):void
Remove a previously registered ICommand to INotification mapping.
Controller

Protected Methods
  Method Defined by
   
Initialize the Singleton Controller instance.
Controller

Protected Constants
  Constant Defined by
    SINGLETON_MSG : String = "Controller Singleton already constructed!"
Controller
Property detail
commandMap property
protected var commandMap:Array
instance property  
protected static var instance:IController
view property  
protected var view:IView
Constructor detail
Controller () constructor
public function Controller()

Constructor.

This IController implementation is a Singleton, so you should not call the constructor directly, but instead call the static Singleton Factory method Controller.getInstance()


Throws
— Error if Singleton instance has already been constructed
Method detail
executeCommand () method
public function executeCommand(note:INotification):void

If an ICommand has previously been registered to handle a the given INotification, then it is executed.

Parameters
note:INotification — an INotification
getInstance () method  
public static function getInstance():IController

Controller Singleton Factory method.

Returns
IController — the Singleton instance of Controller
hasCommand () method  
public function hasCommand(notificationName:String):Boolean

Check if a Command is registered for a given Notification

Parameters
notificationName:String
Returns
Boolean — whether a Command is currently registered for the given notificationName.
initializeController () method  
protected function initializeController():void

Initialize the Singleton Controller instance.

Called automatically by the constructor.

Note that if you are using a subclass of View in your application, you should also subclass Controller and override the initializeController method in the following way:

    // ensure that the Controller is talking to my IView implementation
    override public function initializeController(  ) : void 
    {
     view = MyView.getInstance();
    }
   
registerCommand () method  
public function registerCommand(notificationName:String, commandClassRef:Class):void

Register a particular ICommand class as the handler for a particular INotification.

If an ICommand has already been registered to handle INotifications with this name, it is no longer used, the new ICommand is used instead.

The Observer for the new ICommand is only created if this the first time an ICommand has been regisered for this Notification name. Parameters
notificationName:String — the name of the INotification
 
commandClassRef:Class — the Class of the ICommand
removeCommand () method  
public function removeCommand(notificationName:String):void

Remove a previously registered ICommand to INotification mapping.

Parameters
notificationName:String — the name of the INotification to remove the ICommand mapping for
Constant detail
SINGLETON_MSG constant
protected const SINGLETON_MSG:String = "Controller Singleton already constructed!"