Sequencing multiple commands
24 December, 2006
In your cairngorm Flex 2 application you may require to string a sequence of commands together. This may occur in your application’s initialization process or in the view from a user gesture.
For example, in the case of an e-commerce application on initialization you may be required to get all categories, sub-categories related to a category and the products related to a sub-category all in one process.
In cairngorm each command requires an event to be fired in order to execute the command. Now where you create that next event to be fired is usually in the subsequent command, prior to setting it to that command’s nextEvent property.
Perhaps this approach may not be suitable depending on your commands (as in one my cases) so i created a utility for chaining events together so that a sequence of events can be fired at the developer’s desire.
To demonstrate a scenario of the usage of this utility i have created a small example (click here and right-click to download source) and an illustration of the example.

What i’ve done is create a sub-class of CairngormEvent which has a public property called nextChainedEvent.
Then I’ve create a utility class called EventChainFactory with a method chainEvents, which accepts an array of ChainEvent instances as its only parameter with each event in the array ordered in the order you want your sequence of events fired in. The method returns a ChainEvent instance with each subsequent event set to the next event’s nextChainedEvent property.
Enjoy and dont hestitate to improve it.
Regards,
Bjorn Schultheiss
30 December, 2006 at 6:36 am
Hey Bjorn,
I think your code is week, and your name is that of a tinker bell. You cant handle the Refactor. Do yourself a favor like your Aussie Mate and go swim with some sting rays and leave the Flex-in to The Ceaser. Check the shoulder,
Marco
The Flex Ceaser
30 December, 2006 at 2:45 pm
tinker bell…
my code is weak…
cant handle the refactor!!!
Marco yeah your flex-in, yeah your doing your thing on your thrown.
But there’s some new wiz kids coming up the ranks. I’m just getting started here… You’ve been at this for years, but now you’ve become a target.. I’m coming for you, i’m comin for the thrown and i’ll see you soon.
Regards,
Alien Science (i’m dropping tinkerbell)
25 September, 2007 at 8:12 pm
You might want to check the new alfa version of our framework for sequences implementation in AS 3 and this article that explains the ideas behind them
http://www.gugga.com/flashblog/
http://www.gugga.com/flashblog/2006/10/basics-of-tasks-and-sequences-in_20.html
29 November, 2007 at 10:14 am
Hi.
Good design, who make it?
29 November, 2007 at 10:24 am
me, thanks : )
Bjorn