Today's Flash Meetup: Sequencing Actions in Flex


By daniel - Posted on 29 January 2009

Checked out the Vancouver Flash Meetup for the first time tonight. Ross Ladell runs the show and while tonight's meetup was a little disorganized (he's gotta work, too!), he did present some pretty interesting and useful code.

The Sequencer

Whether you're doing animations or handling multiple asynchronous calls or both, it's not unusual to get into situations where you need to wait for something to complete before moving onto the next step. And the next, and the next.

For example, you might want to play an animation of text spinning twice, before blurring it and then fading out. There are a couple ways you can go about this: event listeners that wait until the first action completes before triggering the next, or a bunch of Timer classes that have been painstakingly synchronized through repeated tests.

Both of those solutions work for small sequences of events but if you're choreographing an epic rather than a short skit, you're in for headaches. Debugging becomes a huge pain when you're tracking chains of event handlers and functions.

Enter the sequencer, which is basically a queue that stores function calls and tweens. You fill the queue with the desired list of actions and it makes sure they executed in the right order.

Ladell's implementation even allows groups of these sequenced items to be executed in parallel. I've put together a quick demo which uses the library.

Just drag the list items around to reorder the events and hit "start" to watch the animation. Stunning, I know</sarcasm>. Seriously, though, you should have seen some of the effects Ladell was composing with the help of this little library. Many thanks for the presentation and source code!

Tags