0

Heyooo I want to incorporate a commandlist into robotlegs, the way i've done it now is to have a commandlist actor funnel out all the commands when not busy, but when the commands are executed robotlegs loses its' reference to the 'contextView'. Meaning i'm doing somehting wrong.

Has anyone any useful tips on CommandLists and Robotlegs? Because i assume it's been done countless times before.

3 Answers3

2

This sounds like you're trying to run a bunch of Commands one after another in response to a single event. My understanding is that you should either have each Command generate an Event that triggers the next Command or simply register all the Commands to the same Event.

You shouldn't ever be touching the value of contextView (to write), so it sounds like you're doing something you shouldn't.

Amy Blankenship
  • 6,485
  • 2
  • 22
  • 45
  • I'm not doing anything to contextview, just realised that i lost the reference to it. What i want is not to queu up a bunch of commands related to another, in that case tying the commands to an event would be a good solution. But what i want is to be able to stuff any command into a queue that is retained and executed after one another. – user1005076 Oct 20 '11 at 12:22
  • I've done something like this for undo and redo functionality, and what I've done is use a doubly linked list. When the command is executed, I store the event in a property of the link. If the action gets undone, then the redo is to simply dispatch the event again later. What you can do in your case is to store the information necessary to create the event, and then have each Command move the cursor to the next link in the list and create and dispatch the next event (detaching the previous action from the chain unless you need undo). – Amy Blankenship Oct 20 '11 at 15:15
  • You can download a sample implementation (with all Interfaces defined for you) of a DLL here http://flexdiary.blogspot.com/2009/12/riadventure-inspiration.html. It doesn't do exactly what you want, but it should give you some ideas. For some other ideas on how you could do this (and a link to a different DLL implementation), check out http://www.developria.com/2009/12/iterative-data-storage-in-as3.html – Amy Blankenship Oct 20 '11 at 15:17
0

You should be interested in that utility for RobotLegs.

CommandLib (SequenceCommand)

  • Also check out @alecmce Command Flow solution for asynchronous sequenced commands. - [source](https://github.com/alecmce/robotlegs-flow-extension) - [description](http://alecmce.com/as3/commandflow-another-approach-to-robotlegs-asynchronicity) – Michał Wróblewski Oct 20 '11 at 19:23
0

How are you executing these commands?

Perhaps you were instantiating and executing them manually?

You should be using the commandMap to instantiate and execute them - this will ensure that their dependencies (like contextView etc) are supplied. For example:

commandMap.execute(SomeCommandClass);

Or (if your commands rely on events):

commandMap.execute(SomeCommandClass, someEventInstance, SomeEventClass);

If you need access to the commandMap in your utility, you might need to inject it:

[Inject] public var commandMap:ICommandMap;

Hope that helps.

darscan
  • 963
  • 1
  • 12
  • 17