Package | com.soma.core.controller |
Class | public class SequenceCommand |
Inheritance | SequenceCommand ![]() ![]() |
Implements | ISequenceCommand |
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 SequenceCommand class is used to execute a list of commands one after the other. The command added can be asynchronous or synchronous.See also
Property | Defined By | ||
---|---|---|---|
commands : Array [read-only]
Retrieves the list of commands added as subcommands. | SequenceCommand | ||
currentCommand : Event [read-only]
Retrieves the command that is currently executed (running). | SequenceCommand | ||
![]() | injector : ISomaInjector [read-only] | Command | |
![]() | instance : ISoma [read-only]
Retrieves the instance of the framework. | Command | |
length : int [read-only]
Retrieves the number of commands added as subcommands. | SequenceCommand | ||
![]() | mediators : SomaMediators [read-only] | Command | |
![]() | stage : Stage [read-only]
Get the stage that has been registered to the framework. | Command |
Method | Defined By | ||
---|---|---|---|
Create an instance of the SequenceCommand class. | SequenceCommand | ||
![]() | addCommand(commandName:String, command:Class):void
Registers a command to the framework. | Command | |
![]() | addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event. | Command | |
![]() |
Registers a model to the framework. | Command | |
![]() | addView(viewName:String, view:Object):Object
Registers a view to the framework. | Command | |
![]() |
Registers a wire to the framework. | Command | |
![]() | dispatchEvent(event:Event):Boolean
Dispatches an event into the event flow. | Command | |
executeNextCommand():void
Method used to execute the next command in the list of subcommands. | SequenceCommand | ||
![]() | getCommand(commandName:String):Class
Retrieves the command class that has been registered with a command name. | Command | |
![]() | getCommands():Array
Retrieves all the command names (event type) that have been registered to the framework. | Command | |
![]() |
Retrieves the last sequence command that has been instantiated in the framework. | Command | |
![]() |
Retrieves the model instance that has been registered using its name. | Command | |
![]() | getModels():Dictionary
Retrieves all the model instances that have been registered to the framework. | Command | |
![]() | getRunningSequencers():Array
Retrieves all the sequence command instances that are running. | Command | |
![]() | getSequencer(event:Event):ISequenceCommand
Retrieves the sequence command instance using an event instance that has been created from this sequence command. | Command | |
![]() | getView(viewName:String):Object
Retrieves the view instance that has been registered using its name. | Command | |
![]() | getViews():Dictionary
Retrieves all the view instances that have been registered to the framework. | Command | |
![]() |
Retrieves the wire instance that has been registered using its name. | Command | |
![]() | getWires():Dictionary
Retrieves all the wire instances that have been registered to the framework. | Command | |
![]() | hasCommand(commandName:String):Boolean
Indicates wether a command has been registered to the framework. | Command | |
![]() | hasEventListener(type:String):Boolean
Checks whether the EventDispatcher object has any listeners registered for a specific type of event. | Command | |
![]() | hasModel(modelName:String):Boolean
Indicates wether a model has been registered to the framework. | Command | |
![]() | hasView(viewName:String):Boolean
Indicates wether a view has been registered to the framework. | Command | |
![]() | hasWire(wireName:String):Boolean
Indicates wether a wire has been registered to the framework. | Command | |
![]() | isPartOfASequence(event:Event):Boolean
Indicates wether an event has been instantiated from a ISequenceCommand class. | Command | |
![]() | removeCommand(commandName:String):void
Removes a command from the framework. | Command | |
![]() | removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object. | Command | |
![]() | removeModel(modelName:String):void
Removes a model from the framework and call the dispose method of this model. | Command | |
![]() | removeView(viewName:String):void
Removes a view from the framework and call the (optional) dispose method of this view. | Command | |
![]() | removeWire(wireName:String):void
Removes a wire from the framework and call the dispose method of this wire. | Command | |
stop():void
Stops the current sequence. | SequenceCommand | ||
![]() | stopAllSequencers():void
Stops all the sequence command instances that are running. | Command | |
![]() | stopSequencer(sequencer:ISequenceCommand):Boolean
Stops a sequence command using the sequence command instance itself. | Command | |
![]() | stopSequencerWithEvent(event:Event):Boolean
Stops a sequence command using an event instance that has been created from this sequence command. | Command | |
![]() | willTrigger(type:String):Boolean
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type. | Command |
Method | Defined By | ||
---|---|---|---|
addSubCommand(event:Event):void
Add a command to the list of commands to execute one after the other. | SequenceCommand | ||
![]() | initialize():void
Method that you can optionally overwrite and that is called after the command has been registered with the framework. | Command | |
initializeSubCommands():void
Method that you can overwrite to add commands to the sequence command. | SequenceCommand |
commands | property |
commands:Array
[read-only] Retrieves the list of commands added as subcommands.
public function get commands():Array
currentCommand | property |
currentCommand:Event
[read-only] Retrieves the command that is currently executed (running).
public function get currentCommand():Event
length | property |
length:int
[read-only] Retrieves the number of commands added as subcommands.
public function get length():int
SequenceCommand | () | Constructor |
public function SequenceCommand()
Create an instance of the SequenceCommand class. Should not be directly instantiated, the framework will instantiate the class.
addSubCommand | () | method |
protected final function addSubCommand(event:Event):void
Add a command to the list of commands to execute one after the other.
Parameters
event:Event — Event instance (must be registered as a command previously).
|
See also
addSubCommand(new MyEvent(MyEvent.DO_SOMETHING_ASYNC));
executeNextCommand | () | method |
public final function executeNextCommand():void
Method used to execute the next command in the list of subcommands.
initializeSubCommands | () | method |
protected function initializeSubCommands():void
Method that you can overwrite to add commands to the sequence command.
See also
addSubCommand(new MyEvent(MyEvent.DO_SOMETHING_ASYNC));
stop | () | method |
public final function stop():void
Stops the current sequence.
addCommand(MyEvent.DO_SOMETHING_ASYNCHRONOUS, CommandASyncExample); addCommand(MyEvent.DO_SOMETHING_ELSE_ASYNCHRONOUS, CommandASyncExample); addCommand(MyEvent.EXECUTE_SEQUENCE_COMMAND, SequenceCommandExample); dispatchEvent(new MyEvent(MyEvent.EXECUTE_SEQUENCE_COMMAND));
package { import flash.utils.clearTimeout; import flash.utils.setTimeout; import flash.events.Event; import com.soma.core.interfaces.ICommandASync; import com.soma.core.controller.Command; public class CommandASyncExample extends Command implements ICommandASync { private var _event:Event; private var _timer:int; public function CommandASyncExample() { } public function execute(event:Event):void { _event = event; _timer = setTimeout(result, 1000, {}); } public function fault(info:Object):void { } public function result(data:Object):void { if (isPartOfASequence(_event)) { getSequencer(_event).executeNextCommand(); } _event = null; clearTimeout(_timer); } } }
package { import com.soma.core.interfaces.ISequenceCommand; import com.soma.core.controller.SequenceCommand; public class SequenceCommandExample extends SequenceCommand implements ISequenceCommand { public function SequenceCommandExample() { } override protected function initializeSubCommands():void { addSubCommand(new MyEvent(MyEvent.DO_SOMETHING_ASYNCHRONOUS)); addSubCommand(new MyEvent(MyEvent.DO_SOMETHING_ELSE_ASYNCHRONOUS)); } } }