Over 10 years of community discussion and knowledge are maintained here as a read-only archive.
Before recommending that I'd like to think through the problem a bit more. (Sorry for not attaching code yet, I will if it makes it easier, but hopefully talking through it will be enough first)If anyone would like to throw out example scenarios here that use subclasses and arguments for it, please do.
sendNotification(StateMachine.ACTION, null, TRY_LOGIN)
if(note.getBody().name == TRY_LOGIN) { // (body of note is a State) // now run login service sendNotification(DO_LOGIN); // (registered to DoLoginCommand)}
public class DoLoginCommand extends AsyncCommand implements IResponder { override public function execute(note:INotification):void { var loginProxy:LoginProxy = facade.retrieveProxy(LoginProxy.NAME) as LoginProxy; loginProxy.login(this); // LoginProxy will execute an HTTPService call and add this command as a responder to the token } public function fault(info:Object):void { sendNotification(StateMachine.ACTION, null, AppFacade.LOGIN) // go back to login } public function result(data:Object):void { /* pseudo code here */ if( data.result) { // (login successful) sendNotification(StateMachine.ACTION, null, AppFacade.MAIN); // go to main } else { // (invalid credentials) fault(null); } }}
var evt:LoginEvent = ... // this has been retrieved from the mediator, and has username & password propertiessendNotification(StateMachine.ACTION, evt, AppFacade.TRY_LOGIN);
...override public function execute(note:INotification) { var state:State = note.getBody(); state.body // (the LoginEvent sent as the body of the TRY_LOGIN action notification)}