Macrobot SequenceCommand issue

cheezywhiz's Avatar

cheezywhiz

15 May, 2013 04:40 PM

Building my first Robotlegs project and things are going great. Nice work, devs!

I'm trying to use Macrobot to sequence a bunch of startup commands, but it's not working as expected. Hopefully someone here that knows Macrobot can clue me in on what I'm doing wrong. I attached a stripped down example of the problem.

TestSequenceCommand should run TestCommandA followed by TestCommandB, but only the first command is running.

Executing TestSequenceCommand outputs:
> TestSequenceCommand
> TestCommandA
> commandCompleteHandler

So the TestSequenceCommand says it's complete as soon as TestCommandA is finished. TestCommandB never starts.

Also weird.. changing TestSequenceCommand to extend ParallelCommand outputs:
> TestSequenceCommand
> TestCommandA
> commandCompleteHandler
> TestCommandB
> commandCompleteHandler

The commandCompleteHandler gets called twice. That doesn't seem right.

Thanks in advance!

  1. Support Staff 1 Posted by creynders on 16 May, 2013 07:58 AM

    creynders's Avatar

    I didn't have the time to drop this into a project and test it out, but at a first glance I don't see anything wrong with it. Did you test this bare bones setup, whether the problem really persists?

  2. 2 Posted by cheezywhiz on 16 May, 2013 08:14 PM

    cheezywhiz's Avatar

    Yes. Here's a screengrab. About as bare bones as I can get. One command that tries to sequence two others. Trace output at the bottom shows that it only runs the first command.

    Image Name

  3. Support Staff 3 Posted by creynders on 17 May, 2013 09:52 AM

    creynders's Avatar

    Ah, now I see it, you need to call the super commandCompleteHandler

         override protected function commandCompleteHandler(success:Boolean):void
            {
                trace('commandCompleteHandler');
                super.commandCompleteHandler(success);
            }
    

    BTW the commandCompleteHandler is called for each executed command, not just at the end of the sequence, so it should be called twice in this case.

  4. 4 Posted by cheezywhiz on 17 May, 2013 01:53 PM

    cheezywhiz's Avatar

    Ah! I mistook 'commandCompleteHandler' to mean the entire SequenceCommand was complete.. but it just means that each sub-command is complete. This revised code does the trick. Thanks a bunch!

    package
    {
        import flash.events.Event;
        
        import org.robotlegs.utilities.macrobot.ParallelCommand;
        import org.robotlegs.utilities.macrobot.SequenceCommand;
        
        public class TestSequenceCommand extends SequenceCommand
        {
            public function TestSequenceCommand()
            {
                super();
                addCommand(TestCommandA);
                addCommand(TestCommandB);
                addCompletionListener(sequenceComplete);
            }
            
            public override function execute():void
            {
                trace("TestSequenceCommand");
                super.execute();
            }
            
            override protected function commandCompleteHandler(success:Boolean):void
            {
                trace("commandCompleteHandler");
                super.commandCompleteHandler(success);
            }
            
            private function sequenceComplete(success:Boolean):void
            {
                trace("sequenceComplete");
                dispatch(new Event(Event.COMPLETE));
            }
        }
    }
    
  5. Support Staff 5 Posted by creynders on 17 May, 2013 02:46 PM

    creynders's Avatar

    Glad to be of help, if there's anything else, let us know!

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac