Flex Caringorm calling multiple command in one call (Queue Command)

293 views Asked by At

I want to call 3 commands one by one , the relation between each commands are command should execute one by one in the previous command result. How to Queue Command's? What is the best practice to handle Queue command , my requirement is adding n number of commands and execute them.

Main -> Execute c1
c1 got the Result - Execute c2
c2 got the Result - Execute c3
2

There are 2 answers

0
mezmo On

I don't believe that you can "queue" commands...what I've done to accomplish the same thing is in the result handler of c1, it attaches the result to event2 which kicks off c2, then c2 does the same with event3 and c3. So it isn't a queuing effect per se, but a chaining one.

HTH

0
Scott On

In your constructor you can define chaining behavior

public function SampleSequenceCommand() {
    this.nextEvent = new MySecondEvent();
}

Then in your result handler of your command you can call the next event

 public function result( event:Object ):void {
    this.executeNextCommand();
 }

Reference for this behavior is here.