Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
If you extend the Command base class, you’ll inherit
injections for the injector, commandMap and mediatorMap properties that are used in
your context, and you’ll get a helper method for dispatching
events:
Example 6-3. The Command class gives you access to the main Robotlegs players
public class Command
{
[Inject]
public var contextView:DisplayObjectContainer;
[Inject]
public var commandMap:ICommandMap;
[Inject]
public var eventDispatcher:IEventDispatcher;
[Inject]
public var injector:IInjector;
[Inject]
public var mediatorMap:IMediatorMap;
public function execute():void
{
}
/**
* Dispatch helper method
*/
protected function dispatch(event:Event):Boolean
{
if(eventDispatcher.hasEventListener(event.type))
return eventDispatcher.dispatchEvent(event);
return false;
}
}