I’ve looked at many frameworks over the years including Cairngorm, Mate, Hive and Gaia to name a few.
None of them have ever really caught my attention enough to feel like I should invest time mastering it.
Enter testing out PureMVC. Obviously this is one of the heavyweights of open source frameworks. I’ve had passing looks at it in the past but never really got into it so thought I’d put together a basic twitter app to give it a go.
The following application simply searches Twitter for the terms “creative”,”inspired”,”amazing” and “bored”,”frustrated”,”stressed” then compares the two sets of positive and negative emotions in a graph to see how inspired the world is feeling at any point in time.
PureMVC does have a quite steep learning curve and just getting to the “Hello World” state does take quite a lot of code. But things are really starting to make sense and I feel like a more mature developer by using it as I can see how much this framework naturally encourages code re-use, scalability and separation of interests.
In my opinion the most important thing is getting your head around the roles and responsibilities of the Mediator, Proxy and Command classes. My understanding of each is as follows.
Proxy classes are cached by the Model and contain code that manipulates a portion of data. Each Proxy represents a data object that may be asynchronous or not and can expose all or part of the data object it represents.
Mediator classes interact with view components and are cached by the View. The Mediator classes interact with the rest of the system to update and respond to interaction to and from the view component it represents.
Commands are only created when needed and is where the logic of the application resides. You create maps to notifications in the Application Facade. When a notification is sent from somewhere in the system that is mapped, a Command instance is created and executed interacting with other actors in the system and sending further notifications as necessary. It can for instance interact with multiple Proxy classes manipulating data in each and send a notification when complete that multiple Mediators are listening to, updating their respective view components as required.
As this is my first experience using PureMVC, any feedback would be most welcome.
Apart from PureMVC there are a number of open source projects that I use and encourage you to investigate if you don’t use them already including:
Bulkloader for loading my external assets.
TweenLite for tweening.
DeMonsterDebugger for debugging (this is awesome!)
Twitterscript for Twitter API interface.
And here is the source.

THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU!
At last a decent flash example in pure mvc – you basicly solved all my issues so thank you!
One thing – could you save the .fla as a cs3 copy for us poor people who adobe screwed when they released the cs4 3 weeks after we brought cs3!
Hey Monkey… sorry for the very delayed reply. Haven’t been getting notifications of comments for some reason. Glad this was useful to you. Here is a CS3 version of the assets if you still need it. http://lab.publicreative.com/uploads/assets.fla
Hi Sakana, yes totally agree PureMVC, Cairngorm etc are definitely for larger applications and in the real world I’d never use a framework for something like this. This is just for demo purposes. I have my own light MVC framework that I use on medium sized projects too. Only on the biggest things we do would we use one of these frameworks.
Hello Mark,
Interesting article… I’m just looking for a framework in actionscript 3 and I found your article. But it seems to me that PureMVC, Cairngorm etc. are more “application”, “flex application” oriented. I mean, I’m flash developer and my everyday job is developing websites (very graphical)… don’t you think a framework like pureMVC is too big for that type of project.
S.
would love to see this…but the example has fallen over
dai
THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU!
At last a decent flash example in pure mvc – you basicly solved all my issues so thank you!
One thing – could you save the .fla as a cs3 copy for us poor people who adobe screwed when they released the cs4 3 weeks after we brought cs3!