Package | com.soma.core.controller |
Class | public class SomaController |
Inheritance | SomaController ![]() |
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.
See also
Method | Defined By | ||
---|---|---|---|
SomaController(instance:ISoma)
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 | ||
getRunningSequencers():Array
Retrieves all the sequence command instances that are running. | SomaController | ||
getSequencer(event:Event):ISequenceCommand
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 | ||
stopAllSequencers():void
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 |
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.
Parametersinstance:ISoma — Framework instance.
|
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.
|
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.
|
Class — A class.
|
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.
ReturnsArray — A sequencer (ISequenceCommand).
|
var sequencer:ISequenceCommand = getSequencer(myEvent);
getLastSequencer | () | method |
public function getLastSequencer():ISequenceCommand
Retrieves the last sequence command that has been instantiated in the framework.
ReturnsISequenceCommand — An ISequenceCommand instance.
|
var lastSequencer:ISequenceCommand = getLastSequencer();
getRunningSequencers | () | method |
public function getRunningSequencers():Array
Retrieves all the sequence command instances that are running.
ReturnsArray — An Array of ISequenceCommand instances.
|
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.
|
ISequenceCommand — A Boolean (true if a sequence command has been stopped).
|
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.
|
Boolean — A Boolean.
|
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 |
Boolean — A Boolean.
|
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.
|
removeCommand(MyEvent.DOSOMETHING);
stopAllSequencers | () | method |
public function stopAllSequencers():void
Stops all the sequence command instances that are running.
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.
|
Boolean — A Boolean (true if the sequence command has been stopped).
|
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.
|
Boolean — A Boolean (true if a sequence command has been stopped).
|
var success:Boolean = stopSequencerWithEvent(myEvent);
addCommand(MyEvent.DOSOMETHING, CommandExample); removeCommand(MyEvent.DOSOMETHING); dispatchEvent(new MyEvent(MyEvent.DOSOMETHING));