Skip to content

Dependency Injection, frameworks and other latest AS3 trends, Robotlegs, Dawn, Parsley?

Attending last LFPUG meetup got me thinking about all the latest Flash and Flex development, especially in the way in which this development is going. I think the community is becoming much more mature and this can be observed by the number of frameworks that have recently poped up. Everyone is blogging about it, and you can actually get lost in all those differences each of the frameworks has. But almost all the frakeworks are build on design paterns, which is definitely a good thing. When it comes to Design Patterns it is pretty straight forward. If you don’t know what they are I suggest doing some research because using design patterns makes your code much more elegant and structured.
Here is what wikipedia says, and remember that wikipedia is ALWAYS right:

n software engineering, a design pattern is a general reusable solution to a commonly occurring problem in software design. A design pattern is not a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations. Object-oriented design patterns typically show relationships and interactions between classes or objects, without specifying the final application classes or objects that are involved.

The whole article can be found here.

Bear in mind that not all the design patterns apply to AS3 because of it’s uniqueness (being an OOP language on client side, not server side). Practical use of design patterns in AS3 was well presented by Eamonn Faherty during the LFPUG’s first session. Eamonn seemed to be pretty confident talking about various patterns and I highly recommend you watch the presentation on LFPUG’s site

If that’s not enough for you, you can always get O’reilly’s book for your iPhone/iPod “Actionscript 3 Design Patterns”. Simply search for “O’reilly Design Patterns” in the app store and this book should come up. I got it myself and I find it really handly to have it will me all the time even if you are only using it to show off what cool apps have. It does the job.

Second session on Frameworks was presented by Richard Lord. Richard is well known in the flash community especially because he’s the man behind Flint, the particle system for flash. That is not the only thing Richard is well known for. Second thing is frameworks. He was even presenting on this year’s Flash on the Beach about frameworks and if you look at his blog it looks like he can call himself an expert. I didn’t make it Richards presentation on FOTB because the conference room got filled out to the max. So for those who had seen it, I recommend you watch what he presented on LFPUG because it seemed that what he added to his FOTB presentation was the most interesting stuff, mainly Parsley and Robotlegs.

I assume all of us heard of Cairngorm, PureMVC and roughty heard of Mate and Swiz.
We constantly hear to stay away from Cairngorm because it’s simply shite (although many of the people who say that have never actually used it), PureMVC is not fun to work with, Mate being only flex framework and Swiz being apparently really good but also working only with flex.

I must admit I am a fan of PureMVC because I believe days of cowboy coding are over. There has to be a unified way of writing code in this industry and PureMVC was the first one to make it happen, especially in the flash department. It’s got it’s pros and cons, but it definitely serves it’s purpose. Code in pureMVC is (usually) neatly organized and if you don’t know it, it means you are way behind.

So what is next?
To me it looks like the next big thing is Dependecy Injection and frameworks build on it. Basically all the frameworks apart from Cairngorm and PureMVC rely on DI. The easiest definition I found:

At the simplest, Dependency Injection is that act of supplying objects with their instance variables or properties. When you pass a variable to the constructor of a class, you are using Dependency Injection. When you set a property on a class, you are using Dependency Injection. If you aren’t coding your AS3 in a strictly procedural or linear fashion, the odds are that you are making use of Dependency Injection right now.

Dependecy Injection always comes with a second term Inversion Of Control. IoC container is nothing else than a container that uses DI, it’s pretty straight forward.

DI and IoC are just one of many things that came to Actioscript from other OOP languages. And I think it’s great. It means we are not re-inventing the wheel, we simply apply the best patterns, aka problem solvers from much more mature languages like Java to AS.

So, looking at what we have available in terms of DI and IoC in Actionscript are the following:

Spring Actionscript (formerly known as Prana).
Prana was the first framework using Inversion of Control for ActionScript 3.0. It was nothing else that a port of Spring Framework for Java. I have never used and I don’t think many people actually have. I think it is mosty the Java reference that puts people off but that’s just my opinion.

SmartyPants IOC
SmartyPants apart from it’s really interesting name it is the one that started the whole Dependency Injection trend. SmartyPants is not a framework itself it is only the IOC container. It is a bit verbose but it’s pretty good to get your head around DI, because it is the only thing it covers.

And here is where we come to the main reason why I wanted to write this post.

Robotloegs is awesome. Robotlegs is a MVCS framework based on on Dependency Injection using Flash Events. Why MVCS? Well the author, Shaun, decided to split the model tier of the architecture into Model itself, accessed via internal API and the service where the external data is loaded into the application. Which sounds pretty resonable approach and it’s a minor change in terms of MVC approach. I personally quite like it. THe next thing you would expect is SmartyPants to handle DI. Wrong! Guys working on Robotlegs decided to write their own dependecy injection tailored to Robotlegs. And so they did giving it anoter original name SwiftSuspenders. Cool thing about Robotlegs it that you are not limited to using SwiftSuspenders. You can choose your own Dependency Injector if you don’t like the one it comes with by default. I started digging a few days ago into RobotLegs and I must admit it is really fun thing to work with.
It’s not what we had with pureMVC where you were told how to use it and that was it.
There are a lot of discussions how Robotlegs should evolve, what should be added, removed and if you have anything good to suggest, you will be heard.
I suggest you start following the Robotlegs google group.

I personally think it will be the next big framework, the pureMVC 2.0. The sooner you get into it the better. It works with Flex as well as Flash, which many of those other frameworks lack, they have no love for Flash. But is it the only solution that works with Flash as well as Flex? Certainly not.

Other player here is Parsley. Parsley has been developed by PowerFlasher, same guys who developed FDT. I haven’t played with it yet, it is definitely on my list. But following people opinions (which I don’t think is the best thing to do), I hear although it is pretty well documented, there is no community behind this framework. This is not gonna put me off but it definitely is a huge disadvantage.

Is that all?
There is one more candidate on the horizon. Probably not many people have heard about this framework. It’s called Dawn. Dawn relies on SmartyPants it’s own DI and is also inspired by Guice (just like the SmartyPants itself). If you are into checking it out, I suggest you visit their site and if you live around London, Sam, the author, will be presenting it on next FLUG on 17th of November 2009.

Robotlegs is gaining loads of momentum, it is definitely worth checking it out. I guess the whole DI stuff if fairly new and it is interesting how things are gonna go with it. But keep your eyes open on Parsley as this it the framework that apparently Adobe uses and their Caringorm 3 is pretty much gonna be like Parsley, from what I’ve heard. Also have a look at Dawn it might turn out to be also big.

If you have any questions, comments, or you disagree let me know :)

Posted in development, Uncategorized.

Tagged with , , , , , , , , , , , .

26 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Jörg says

    Great write-up, thanks a lot.
    BTW, Parsley is not developed by Powerflasher, but rather Spicefactory ( Anyways, both companies appear to have a pretty close relationship.

  2. Joel Hooks says

    Here is the article on AS3 Dependency Injection I wrote for InsideRIA. I was trying to distill down the disparate (and often confusing) definitions of DI/IoC one runs across when researching the topic.

  3. Timo says

    Nice article, i do prefer Robotlegs too :)
    Since you were talking about designpatterns, you should refer to Great Examples about using Design Patterns with Actionscript.

  4. Ruprict says

    Haven’t had the time to look at robotlegs, but we use Cairngorm and Spring Actionscript and do quite well. Spring actually has a bunch of conventions that abstract some of Cairngorm’s uglier features away and make using it a bit more fun and flexible.

    I know you aren’t a fan of Cairngorm, but we do OK with it. I am interested in looking at robotlegs, hope to get the chance soon.

    Great post, btw.

  5. Matt W says

    It should be noted that Robotlegs is only compatible with Flash content compiled with the Flex SDK and not Flash CS4. The compiler doesn’t support meta data tags yet. Kind of a bummer. Hope this changes with CS5.

  6. shaun says

    Nice writeup. I’d like to mention that Robotlegs was originally built on top of SmartyPants, and has been successfully run with Spring ActionScript. They were both a bit bulky, and Till Schneidereit (who is now a Robotlegs contributor) was kind enough to whip up the lightweight SwiftSuspenders library which we now use as the default.

    @Matt W: There have been some advances on that front lately. SwiftSuspenders can now use XML configuration for injection points which allows Robotlegs applications to be compiled from Flash CS4. I haven’t tried this out myself yet, but I’ve heard reports that it works well.

  7. admin says

    Hey Guys,
    Thanks guys for all the comments, much appreciated.

    Like I said, there is not much on Parsley and that’s one of the reasons why I wrote it’s developed by the same guys as FDT.

    Cheers Shaun for poppin here and well done on Robotlegs!

  8. dejavu says

    Very good. You just inspired me to start writing the great history of AS3 frameworks… And all these comments on one day! So much going on in AS3.

  9. Dan Carter says

    “It should be noted that Robotlegs is only compatible with Flash content compiled with the Flex SDK and not Flash CS4.”

    There is now a nometa version of Robotlegs that is xml configurable rather than via metadata so can be used in IDE

  10. Joel Hooks says


    You don’t need to use nometa to utilize the XML injection configuration.

  11. Ben Clinkinbeard says

    SmartyPants was far from the first DI framework for the Flash Platform. Swiz and Mate were around (and fairly popular) before SmartyPants was even released.

  12. admin says

    Hi Ben,

    That’s exactly what I wrote.
    “Basically all the frameworks apart from Cairngorm and PureMVC rely on DI”

    SmartyPants was the first IoC Container for AS3 on it’s own.

  13. Joel Hooks says

    Cairngorm and PureMVC are both DI, they just use Service Locator pattern as the mechanism.

  14. admin says

    Hi Joel,

    What do you mean they are both DI? Could you please explain?
    Cairngorm and PureMCV use Service Locator pattern, they use a registry ( eg. facade in pMVC ) and they retrieve actors (eg. facade.retrieveProxy) which is not too good, because you end up having a couple of singletons that are hard to unit test. DI makes is easier by removing the registry ( so you don’t have to be doing facade.retrieveStuff ) and keeping your classes decoupled.
    Have a look here, it’s from the guy who invented the pattern:

    If you look in:
    Using a Service Locator he states:
    “Injection isn’t the only way to break this dependency, another is to use a service locator.”

    Many people state that DI is an alternative to Service Locator pattern, therfore I don’t agee that pureMVC and Cairngorm can be called DI frameworks.

  15. Ben Clinkinbeard says

    Hi Tom,

    “SmartyPants was the first IoC Container for AS3 on it’s own.”

    That may be the case and I have no problem with that statement.

    I was referring to the line “[SmartyPants] is the one that started the whole Dependency Injection trend”. If that is intended to imply “for pure AS3″ or “that does nothing but DI/IoC” that is not apparent.

  16. Sam says

    Hey Tom,

    Sam here (author of Dawn), thanks for taking a look at it! I did that talk at FLUG the other night. I popped the slides up here

    Also Dawn doesn’t rely on SmartyPants, it has its own DI core… but since they are both derived from Guice they look pretty similar

    Cheers mate,

  17. admin says

    Hi Sam,

    I was a good presentation, you made it look really simple. Thanks for the slides and thanks for clarifying on SmartyPants.


  18. Tom says

    It’s great to see such progression in the Flex frameworks space over the last few years. I wrote a post on a similar subject back in July (, but you highlight a few more frameworks that have arrived since then. There must be some opportunities for consolidation.

    Please allow me to correct a few points re. Parsley and Cairngorm. You wrote that apparently Cairngorm will be pretty much like Parsley, but the truth is more subtle. Some of the Cairngorm beta libraries are implemented as Parsley extensions, because Parsley provides extensibility points that make it easy to create higher-level framework features. Also, the Cairngorm sample applications demonstrate some design patterns, such as the Presentation Model and Command, and in these Parsley is used as the underlying IoC container and messaging framework. We do find Parsley to be a mature and extensible framework, but that is not to discount the other frameworks, which offer their own distinguishing features and characteristics.

    Cairngorm itself is undergoing a transformation. The committee acknowledges that the important patterns and practices for RIA development can be applied with a variety of frameworks, and IoC containers provide an elegant means. For instance, instead of declaring services in a Cairngorm service locator, one might declare them in an MXML Parsley config class, a Swiz BeanLoader or a Spring ActionScript XML file. Then the service can be injected into the delegates/commands/etc automatically instead of being retrieved though a locator. The mechanism for dependency-inversion has changed, but the separation of concerns and underlying design patterns remain.

    So going forwards you can expect Cairngorm to become more focussed on patterns and practices. The Cairngorm Committee won’t seek to compete with all the latest frameworks, but rather to embrace and encourage them. Cairngorm will aim to provide guidance to help enterprises deliver large Flex projects successfully and where possible this will be framework agnostic. This transition is very much in progress, but we hope the result will promote the continuing development of frameworks, from the trend towards inversion-of-control containers, to the emerging modularity frameworks, like Potomac and Adobe Gravity.

  19. admin says

    Hi Tom,

    Thanks for your input. The future of Cairngorm seems to look interesting from what you’d written. I am looking forward to it’s official release.

  20. Renu says

    Well done. The description is very straight forward.
    Thanks for sharing it

  21. dien dan mua ban says

    Nice article, i do prefer Robotlegs too :)
    Since you were talking about designpatterns, you should refer to Great Examples about using Design Patterns with Actionscript.

  22. mua ban laptop says

    Very good. You just inspired me to start writing the great history of AS3 frameworks… And all these comments on one day! So much going on in AS3.

  23. Underfloor heating mats says

    I was a great presentation, you produced it search actually straightforward. Many thanks for the slides and thanks for clarifying on Smarty Pants.

  24. STRATO says

    Excellent. You just inspired me to start out writing the great background of AS3 frameworks… And all these comments on one particular day! A lot happening in AS3.

  25. hava perdeleri says

    Thank you, that your site is very nice touch topics that up until a date and I congratulate you for the labor of a successful site

  26. Dien dan mua ban says

    Nice article, thanks for sharing

Some HTML is OK

or, reply to this post via trackback.