Return to table of contents
All command classes are inherited from class
Command. By name, commands perform something. Every command has
execute() which does the job, and emits progress and complete event, and possibly error event.
The base class,
Command, has the following three main functions:
public function execute() : void protected function notifyComplete() : void protected function notifyProgress( progress:uint, progressMessage:String = null ) : void protected function notifyError( msg:String ) : void
execute() function has to be overridden and implemented by subclasses. Other functions in a command class are usually private — this makes perfect sense as commands are supposed to execute only.
When using (or calling) a command, ED usually does this (using InitApplicationCommand as an example):
var cmd : InitApplicationCommand = new InitApplicationCommand( stage ); cmd.addEventListener( CommandCompleteEvent.COMPLETE, onAppInitComplete ); cmd.addEventListener( CommandProgressEvent.PROGRESS, onAppInitProgress ); cmd.addEventListener( ErrorEvent.ERROR, onAppInitError ); cmd.execute();
You will find this pattern again and again in ED.