I did an article when I switched from PureMVC to Robotlegs so I am going to do something similar here. Yesterday I was able to do everything I wanted with Robotlegs 2, enough to do a full project with, but it wasn’t straight forward. Hopefully this will save you some time.
OMG they removed the org
First thing you will notice in the git repository is that they removed the org package; it starts right at robotlegs. No more org.robolegs.somethingelse. I was kinda confused at first. I thought I was at the wrong place. I kept looking for the src. But after reading this discussion about it, I figured I was at the right place. It did make much sense at first and it was pretty confusing, but in the end it doesn’t change much. Doesn’t help much either, but we will get use to it I guess. Goodbye org package!
Bender full of women
They next package inside the robotlegs source folder is bender. Funny thing, English not being my first languages I was thinking of binders and I didn’t get it… Silly me, well it refers to Bender, the robot character from Futurama. It is meant as a version name (version number) so version 2 is named Bender, version 3 will be some other robot I guess. This is a like what Google is doing with Android and naming every version of its operating system as a dessert (Ice cream sandwich, Jelly Bean, Gingerbread, etc). Again a bit confusing; I would have gotten it right away if I had seen v2, but bender is great once you know about it (first emoticon I put in a post)
Putting it into context
Next little problem I had was when I created the context. The code on the git page is great but it only gives you half of what you should write. So here is what they have on their page:
_context = new Context().install(MVCSBundle).configure(MyAppConfig, SomeOtherConfig).configure(new ContextView(this));
Now this is all good and nice, so I paste this in my project, and than I put my variable statement for _context at the top of my Class and I naturally type it to Context. Error, here is the silly error it returned : “Error: Implicit coercion of a value with static type robotlegs.bender.framework.api:IContext to a possibly unrelated type robotlegs.bender.framework.impl:Context.”. Now I’m like OMG, WTF, I think I should be right about everything. Well not this time. You need to type your _context as IContext; took me a little while to figure it out (hopefully having the error pasted in this post will save you some time). So:
private var _context:IContext;
MVCS but where is my command map?
This one was easy, I was looking to map some commands, but couldn’t find the right class. I am in FlashDevelop and I start typing CommandM and two classes pop up CommandMapper and CommandMapping. Sounds somewhat good, but doesn’t seem to be the right thing. After some looking around in the examples, the class I was looking for was IEventCommandMap, once you inject that, you are golden.
[Inject] public var commandMap:IEventCommandMap;
And finally the ContextView
So yeah, last thing I needed to do was to add some views on the stage, but where to start? Answer: pretty much everywhere! Inject the ContextView where you need it, after that you can add views to its view. Hum sounds confusing here is some code:
[Inject] public var contextView:ContextView;
So I got all my building blocs that I am used too in Robotlegs v1 so I could technically build a project using it. V2 feels good, I like the new syntax to create the Context and to map mediators and commands. It seems to be doing way more than what I am used too, there are a lot of extensions that I didn’t investigate. But hey, time will tell if it can hold its own.