11/03/2011

RobotLegs and runtime parameters

 

Been recently getting back into using RobotLegs, to create some Smart Ads. One of the great things about RobotLegs is the amazing support on the website. There is a great Knowledge Base (including docs, a forum, articles and updates).

I was looking through the knowledge base for a old question I asked when I last used RL. Then I wanted to know a way to load external settings sent in via FlashVars. First I wanted to know how to access them and how I could use them in multiple parts of the application.

The fantastic RobotLegs community gave me some great answers, and at the time I was more than happy. The answer I was given was that it is possible to access the FlashVars parameters using:

contextView.loaderInfo.parameters

And that you can access the contextView in any part of a RobotLegs application using:

[Inject]
public var contextView:DisplayObjectContainer;

So I thought that's cool, I'll use that to access the runtime parameters throughout my application.

The new RobotLegs application I'm build I again have to access the runtime parameters, but this time I decided instead of injecting the contextView everywhere and getting the runtime params this way. I've decided to access them during the start up of the application, then store them in the model.

The reason I've decided to do this is because I think it is better practice to get these parameters into the model in case I want to work on the passed parameters , maybe I want to parse them, or dispatch a event to change the view based on setting from the parameters.

So I decided that this is a better option, one of the great benefits of RobotLegs is that it allows you the flexibility to change how you may do things. The framework only suggests how you should build your app, not defines a single way that you must create an app.

No comments: