AS3 on PureMVC. Round One.

As referenced in the title, this article is about coding Actionscript 3.0 in a Model-View-Controller design pattern, namely the PureMVC way.

Problems don’t exist. Only opportunities for creating solutions.

A few years back, when I started on web design / development, it was a one-man show. I then started working with other developers from time to time. Two years ago, I joined a team of Adobe Flash developers, and only then I realized how many routes a single coding task can take. We all have different approaches on coding and with this in mind, I felt the need to find a standardized way of developing Adobe Flash based websites / applications.

Last year, after a lot of online research on Actionscript frameworks, I found PureMVC to be the most stable, mature and — most importantly — well documented.

Kicking the tyres.

Before having other team members sharing my opinion, I had to try it myself and apply all the concept on a real project.

My first approach on this design pattern — by the time of publishing this article — is still to be available online. It’s nothing too fancy, but what’s on focus here, is the code holding the pieces together. It’s a structure built to support three websites with similar content for Casinos de Angola. Two websites are on an ongoing approval process, while the third is still to be designed.

“If anything can go wrong, it will.”

Having little to no experience using the MVC pattern, and a deadline to meet, it was a risky choice to make. But still, I opted to take this road. And so — validating the aforementioned Murphy’s Law — I failed the initial deadline.

The development process took waaaaaay longer than I expected. Not because there was a lot to code, but because there was a lot to learn in order to get a solid ground to start building with the chosen architecture.
A big learning curve of concepts before getting into any real coding is a bummer.

Happier programming.

What do you think about the idea? Sounds good, right? It feels even better!
The framework enables a loose coupling between resources allowing an easy development of really project independent components. Maybe this is geek / coder talk, but it feels a more Human-like communication between abstract project resources. Bare this in mind: the notifications are a bliss to work with!

Being an avid follower of the Don’t Repeat Yourself principle and a control freak for logical organization and standardization I chose to implement a Convention Over Configuration paradigm by specifying the website structure / layout in a single XML (Model) file.

As most developers, if I can avoid extra work, by automating processes, I do. Better yet: if I can avoid starting a new project from scratch, and just re-factor 10-15% code of a previous one, I SURE do. And that’s what happened. Having the website contents (Model/Proxies) automating the layout (View), only a few bits of the business logic (Mediators) had to be changed. Now THIS is (planned) code reuse!

Wrapping up…

“The concept of PureMVC may make the best of us shy away, but once you’ve got your head around the bare fundamentals, you’ll soon be flying your way around it.” — Ahmed Nuaman said it on the first tutorial on PureMVC I’ve read, and I could not agree more (though I’m still learning the flying part).

I’m currently — at the time I started writing this article — finishing the development of two video players with similar functionalities, and everything is running smoother and faster. The first player took around 7 hours to complete. The second one? 45 minutes!

One of the biggest conclusions I found with this road I took was that allowing myself to fail, brought an enormous bandwagon of knowledge and rewarding experience. Only by trying harder and harder every now and then, and subsequently failing a lot of those times, you will broaden your comfort zone and therefore your horizons.

Maybe there’s an influence here from the OFFF’s 2009 edition theme: “Fail Gracefully” and the “This isn’t flying, this is falling with style” quote from Toy Story.

Want to learn more about AS3 on PureMVC?

Follows a list of articles / tutorials / books I’ve read, that I think are important for anyone that would like to learn more on the subject:

I’ll be keeping this list updated with new articles / tutorials / books once I find and read them.

Any feedback?

Do you use PureMVC or have tried it? Like it? Hate it? Maybe another framework?
I would love to hear your opinions and to know whether or not I should go for a “Round Two” article on the PureMVC subject.
Your feedback will be much appreciated!

For updates on more articles like this, you can signup for email updates, subscribe the blog’s RSS Feed or follow me on Twitter.

Photo by Jean Scheijen.

This entry was posted in Codes and tagged , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.


  1. gaspar
    Posted May 4, 2010 at 12:42 | Permalink

    Do you still use it? How does it survive the test of time?

    • Posted May 4, 2010 at 16:08 | Permalink

      Yes, I’ve been using the PMVC framework for every AS3 project ever since. From small apps like video players, photo sliders and panoramic navigation to a Augmented Reality game and dynamic websites.

      Currently I’m using templates with common / basic features to avoid developing from scratch every new project.
      I’ll get these templates ready with comments, and make the source available online during next week.

      I think it helps having live samples to study from, instead of just reading documentation.

  2. Johny
    Posted October 4, 2010 at 06:13 | Permalink

    Hi João Pescada,

    I’m very interested in seeing your code as i’m still learning pureMVC…. May i see your code?

    (i can’t find your code anywhere)

    Thanks a lot

    • Posted October 4, 2010 at 20:03 | Permalink

      Hi Johny,

      I totally forgot about the templates referred above… started to get them ready, but never finished it.

      Is there any specific project that you would like to get a template for? So I can prioritize and share the code…

      • Johny
        Posted October 6, 2010 at 05:31 | Permalink

        Hi Man,

        well, for me and other people who just started to learn PureMVC, we need to know what is the basic guideline for creating an app or a website

        i.e. what code goes where, etc

        for a recent project, i’m gonna use PMVC for creating a e-commerce website with lots of interactivity.

        thanks for sharing man :D

        • Posted October 14, 2010 at 12:21 | Permalink

          Hello again!

          I was going to suggest a great link posted in the blog from Yee Peng Chia, but it’s currently not available online…

          So, I’ll be developing a new website in the next weeks, using PMVC.
          The base code will be prepared as a template for future projects, and I’ll start posting it next week with a walkthrough.

          Hope it helps. :)

  3. Posted December 25, 2010 at 21:56 | Permalink

    […] This post was mentioned on Twitter by Geirr Winnem, João Pescada. João Pescada said: Posted a new article on my blog: AS3 on PureMVC. Round One. #flash #actionscript #as3 #puremvc #mvc #oop […]

2 Trackbacks

Leave a Reply

  • Subscribe to get my
    best content.

    Delivered for free to your inbox, every
    two weeks.

    No spam, ever. Unsubscribe any time.

  • Advert

  • On Twitter