SyntaxScrewer's Blog

February 12, 2010

RobotLegs example using Flash CS4. // incomplete

Filed under: Flash — geekymaira @ 11:54 am

This is a basic robotlegs implementation with the help of an example in Flash CS4.

I’d like to point out 2 resources without which I couldn’t have ever writen this.

Justin’s Tutorial

Helmut Granda’s Article

If you’re new to RobotLegs and don’t really understand it, I recommend that you go through this post first.

There are a few things I’d like to clarify before you download the example.

First of all,  Flash CS4 does not recognize metadata tags. This causes a problem with injections when you use the [inject] metadata tag. To overcome this problem, I’ve modified theXML_CONFIG for the injector. (Look at Helmut Granda’s Article). To give you a really short description of how this is done.

In your context class, you add 2 extra things.

A) In the class you declare a variable called XML_CONFIG and you mention all the injections that will be used in various classes in your project. This is like  a roadmap for the injector to use.
The rule of thumb is that if you’re going to be using the [Inject] metadata tag in a class for injection, then that class must have an injection rule defined in the following XML.

protected static const XML_CONFIG:XML =
 <type name='com.smaira.view::RectangleBoxMediator'>                 // The path of the class which requires the injection
 <field name='view'/>                                                                                          // The names of the fields in class into which the injections will be made.
 <field name='appModel'/>
 <type name='com.smaira.view::MessagePopupMediator'>             // The path of the class which requires the injection
 <field name='view'/>
 <field name='appModel'/>                                                                              // The names of the fields in class into which the injections will be made.
 <type name='com.smaira.controller::CreateRectangleCommand'>
 <field name='appStage'/>

B)  Next you add a statement before making the super call in your Context class constructor.

injector = new SwiftSuspendersInjector(XML_CONFIG);

What that does is that it creates the Injector with the XML_CONFIG defined in step 1.

The second thing I want to clarify is that  it may seem to you that making so many classes and implementing a whole framework is a lot of overload for doing something so simple. Well, that’s correct. It is. But having said that, please note that this example is just for the sake of  building a demo around what I talked about in the “What is RobotLegs” post. Usually, in reality, a framework would be helpful when it’s used for bigger projects. In fact,
it’ll be really helpful !!! .

You can download the source from here :  RobotLegs Example

NOTE : The code is heavily commented, so that you don’t get lost 🙂 ,  but I hope you don’t get lost in my comments!!!




Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at

%d bloggers like this: