Packagecom.soma.core.controller
Classpublic class SomaController
InheritanceSomaController Inheritance Object

Author: Romuald Quantin - www.soundstep.com

Resources: http://www.soundstep.com/downloads/somacore

Actionscript version: 3.0

Copyright: Mozilla Public License 1.1 (MPL 1.1) http://www.opensource.org/licenses/mozilla1.1.php

The SomaController handles the commands added to the framework and the events dispatched from eiher a display list or a framework element (instance of the framework, commands or wires).

All the events dispatched with a property bubbles set to false will be ignored, that's why the event mapped to a command class must have this property set to true.

You can add commands, remove commands and dispatch commands from: the framework instance, the stage, any DisplayObject (as long as it is added to the stage), a wire, a command or a model using its dispatcher property.

You can create 4 types of commands: synchronous (Command), asynchronous (Command that implements ICommandASync), parallel (ParallelCommand) and sequence (SequenceCommand). See each class for a detailed explanation and examples.

You can use the properties of a custom event to send parameters and receive them in the command.

View the examples

See also

com.soma.core.controller.Command
com.soma.core.controller.ParallelCommand
com.soma.core.controller.SequenceCommand
com.soma.core.interfaces.ICommand
com.soma.core.interfaces.ICommandASync
com.soma.core.interfaces.IParallelCommand
com.soma.core.interfaces.ISequenceCommand


Public Methods
 MethodDefined By
  
Create an instance of the SomaController class.
SomaController
  
addCommand(commandName:String, command:Class):void
Registers a command to the framework.
SomaController
  
dispose():void
Destroys the SomaController elements (all commands, sequencers and properties).
SomaController
  
getCommand(commandName:String):Class
Retrieves the command class that has been registered with a command name.
SomaController
  
getCommands():Array
Retrieves the sequence command instance using an event instance that has been created from this sequence command.
SomaController
  
Retrieves the last sequence command that has been instantiated in the framework.
SomaController
  
Retrieves all the sequence command instances that are running.
SomaController
  
Stops a sequence command using an event instance that has been created from this sequence command.
SomaController
  
hasCommand(commandName:String):Boolean
Indicates wether a command has been registered to the framework.
SomaController
  
isPartOfASequence(event:Event):Boolean
Indicates wether an event has been instantiated from a ISequenceCommand class.
SomaController
  
removeCommand(commandName:String):void
Removes a command from the framework.
SomaController
  
Stops all the sequence command instances that are running.
SomaController
  
stopSequencer(sequencer:ISequenceCommand):Boolean
Stops a sequence command using the sequence command instance itself.
SomaController
  
stopSequencerWithEvent(event:Event):Boolean
Stops a sequence command using an event instance that has been created from this sequence command.
SomaController
Constructor Detail
SomaController()Constructor
public function SomaController(instance:ISoma)

Create an instance of the SomaController class. Should not be directly instantiated, the framework will instantiate the class.

Parameters
instance:ISoma — Framework instance.
Method Detail
addCommand()method
public function addCommand(commandName:String, command:Class):void

Registers a command to the framework.

Parameters

commandName:String — Event type that is used as a command name.
 
command:Class — Class that will be executed when a command has been dispatched.


Example
addCommand(MyEvent.DOSOMETHING, MyCommand);
dispose()method 
public function dispose():void

Destroys the SomaController elements (all commands, sequencers and properties).

getCommand()method 
public function getCommand(commandName:String):Class

Retrieves the command class that has been registered with a command name.

Parameters

commandName:String — Event type that is used as a command name.

Returns
Class — A class.

Example
var commandClass:ICommand = getCommand(MyEvent.DOSOMETHING) as ICommand;
getCommands()method 
public function getCommands():Array

Retrieves the sequence command instance using an event instance that has been created from this sequence command.

Returns
Array — A sequencer (ISequenceCommand).

Example
var sequencer:ISequenceCommand = getSequencer(myEvent);
getLastSequencer()method 
public function getLastSequencer():ISequenceCommand

Retrieves the last sequence command that has been instantiated in the framework.

Returns
ISequenceCommand — An ISequenceCommand instance.

Example
var lastSequencer:ISequenceCommand = getLastSequencer();
getRunningSequencers()method 
public function getRunningSequencers():Array

Retrieves all the sequence command instances that are running.

Returns
Array — An Array of ISequenceCommand instances.

Example
var sequencers:Array = getRunningSequencers();
getSequencer()method 
public function getSequencer(event:Event):ISequenceCommand

Stops a sequence command using an event instance that has been created from this sequence command.

Parameters

event:Event — Event instance.

Returns
ISequenceCommand — A Boolean (true if a sequence command has been stopped).

Example
var success:Boolean = stopSequencerWithEvent(myEvent);
hasCommand()method 
public function hasCommand(commandName:String):Boolean

Indicates wether a command has been registered to the framework.

Parameters

commandName:String — Event type that is used as a command name.

Returns
Boolean — A Boolean.

Example
hasCommand(MyEvent.DOSOMETHING);
isPartOfASequence()method 
public function isPartOfASequence(event:Event):Boolean

Indicates wether an event has been instantiated from a ISequenceCommand class.

Parameters

event:Event

Returns
Boolean — A Boolean.

Example
var inSequence:Boolean = isPartOfASequence(myEvent);
removeCommand()method 
public function removeCommand(commandName:String):void

Removes a command from the framework.

Parameters

commandName:String — Event type that is used as a command name.


Example
removeCommand(MyEvent.DOSOMETHING);
stopAllSequencers()method 
public function stopAllSequencers():void

Stops all the sequence command instances that are running.


Example
stopAllSequencers();
stopSequencer()method 
public function stopSequencer(sequencer:ISequenceCommand):Boolean

Stops a sequence command using the sequence command instance itself.

Parameters

sequencer:ISequenceCommand — The sequence command instance.

Returns
Boolean — A Boolean (true if the sequence command has been stopped).

Example
var success:Boolean = stopSequencer(mySequenceCommand);
stopSequencerWithEvent()method 
public function stopSequencerWithEvent(event:Event):Boolean

Stops a sequence command using an event instance that has been created from this sequence command.

Parameters

event:Event — Event instance.

Returns
Boolean — A Boolean (true if a sequence command has been stopped).

Example
var success:Boolean = stopSequencerWithEvent(myEvent);
Examples
addCommand(MyEvent.DOSOMETHING, CommandExample);
removeCommand(MyEvent.DOSOMETHING);
dispatchEvent(new MyEvent(MyEvent.DOSOMETHING));