Articles

Wait for user input in your sequence

We’ve been using the task based sequence for a while now and are very pleased with it. One thing we missed, was the possibility to listen to an event.

Besides the ConditionalTask (which waits for an other Task to be completed), we’ve now added the EventListenerTask. This task waits until an object has dispatched an event before continuing the sequence.

Here is a code example

//create a new sequence that will hold tasks
var sequence: Sequence = new Sequence();
//wait until the user clicked on the 'myButton' instance
sequence.add(new EventListenerTask( myButton, MouseEvent.MOUSE_DOWN );
//call a callback method in the present scope
sequence.add(new CallbackTask(onDone));
//start the sequence
sequence.execute();

With this new Task it’s very easy to (for example) pause the Sequence until the user pressed a button or pressed a key… or until some other object dispatched an event.

2 Responses to “Wait for user input in your sequence”


  1. 1 Sebas

    Hello,

    your sequence class is great and I’m happily using it.
    I have a question though, have you thought to let a task use as input data the output of the previous task? I think it would be interesting and useful.

  2. 2 Thijs

    The event listener is set in the ‘executeTaskHook’, but what if the Task is part of longer list of Tasks and the user clicks before this task is executed? Maybe you should add the listener in the constructor of the Task? Or at least set this as an option?

Leave a Reply