background preloader

RobotLegs

Facebook Twitter

RobotLegs clock example walkthrough 1 – views, mediators and context | Cambiatablog. I’ve been trying to get the grips on dependency injection in AS3 for a while. Robotlegs MVCS framework ( is causing the most buzz in the community now, but it seemed to be a too big step for me: not only dependency injection, but also at the same time mediators classes, commands, scary metatags… Well, after fiddling some hours with more DI-specific libraries like SmartyPants ( and Dawn ( I’m now back to RobotLegs, and I think I like it! :-) So, here’s a walkthroug of an MVC clock example. I’ts inspired by the Vizio clock app ( but also takes some UI action with start/stop buttons.

Source code for this walkthrough can be found here. So, let’s first take a look at the app we are going to build. It’s a very basic clock example with one label showing the current time, and two buttons – one for start and one for stop: ClockViewMediator.as 1. Robotlegs. Jeffry Houser's Blog: Learning RobotLegs Part 1: Context and Mediators. I wrote this for DotComIt's December newsletter, which you can sign up for over at the Flextras site. One of the more popular series of blog articles I've written is my series on learning the Cairngorm Framework.

It was a six part series on my experiences learning, and using, Cairngorm during the first major project I used with it. It has three and a half years since I started that series, and the Flex Framework landscape has shifted tremendously. There are more frameworks than you can shake a stick at. I am now working on a project that will use RobotLegs and I thought I'd write a similar series on my experiences.

This newsletter is the first entry in that series. What is the Context? There are three primary tutorials on InsideRIA about RobotLegs. As best I understand it, a context object is a global framework object that sets up everything and makes the framework magically work. My context looks like this: What is a Mediator? A Mediator is a design pattern. This is a sample mediator: Robotlegs Website Example Tutorial, Part II. In the first part of this tutorial I discussed the process of wiring up views to mediators, injection of the model and the view and mapping an event to a command.

In this part, I’m going to discuss the process of mapping view events to their mediators, the use of the Command object as a controller and outline the overall flow of events in this sample website app. See the first post to see the demo app running and to download the source code. Mapping View Events to Their Mediators The place to map a view’s events to its corresponding mediator is inside the mediator’s onRegister function which Robotlegs calls when the app is starting up.

In this demo site, I have created a simple navigation menu inside a component called NavMenu.mxml. In this scenario, Robotlegs offers a couple of methods of mapping events. With this statement (which could be added to the onRegister function), all mouse click events originating from the nav menu would be dispatched to the mediator. Conclusion. Why Robotlegs For Games? | Flex & Flash Consultant – Jesse Warden dot Kizz-ohm.

Why Robotlegs for Games? The following covers why you would utilize the Robotlegs MVC architecture in a lightweight, Lua game for Corona. I’ll discuss the refactoring reasoning, the common problems you run across in game architecture, and their solutions with their pro’s and con’s discussed. Finally, I conclude on how Robotlegs helps solve these common issues, specifically in a Lua & Corona context. I’ve started the port of Robotlegs to Lua to work in Corona if you’re interested in learning more. Refactor First In learning Lua & Corona, I quickly ran into 2 problems with the game I’m working on. The first thing was to start using classes. The second thing was to start using packages.

These are the low hanging fruit of re-factoring, and has made a huge difference in code readability & maintainability. Burdens of Encapsulation The downside of OOP is that it’s encapsulated. You have 3 options: globals, messaging dependencies, or mediation. Global Variables: The Good In Lua, globals are all 3. Building Blocks - The Adventures of Joel Hooks and His Faithful Friend Code.