I’ve been meaning to get stuck in to MVC patterns with AS3 for a while now and had been hearing lots of good things about PureMVC. Got a little project the other day that I think is perfect to use as an introduction. I’ll be writing about the process as I go, which will definately be a journey of discovery. I’m sure I’ll take some wrong turns along the way, but I ‘m hoping at the end of it I’ll have left an informative trail for anyone else wanting to try PureMVC.
So, for the project:
The basic layout uses an arcordian style approach to display 3 different pieces of content:
The content will load via XML and use a slide transition to switch from tab to tab.
Understanding MVC concepts
Having never worked with an MVC approach I found it a bit daunting diving straight into PureMVC at first as they’ve extended the paradigm to include a Facade as well as Proxies (to work with the Model), Mediators (to work with the View) and Commands (to work with the Controller). there’s a lot of jargon to learn and I admit it took me a couple of days to get my head around it. Luckily I did all the heavy lifting as far as this is concerned a while back, so with a quick refresher on the main actors, their assistants and their tasks I feel like I’ve got a pretty solid understanding of the concepts involved. I’m sure I’ll be eating my words soon enough though.
So I’m now ready to start building my application. I’m actually not exactly sure where to start. I’ll be using Flash CS4, so I’ve set up a document class called Main.as which doesn’t do anything yet besides send through a stage reference to the custom ApplicationFacade class. I’ve also created my generic Tab and Content Movieclips and exported them for use with actionscript in anticipation of adding them to the stage when the time comes.
So I guess the first step is to load the XML data sheet that will provide the content data for the application. This will involve an asynchronous process so I’m guessing I’ll need a notification to tell the application when the file is loaded. The XML is part of the Model of the application, so I guess I’ll be creating a Proxie to store the data once it’s loaded. I’m currently looking at the Start Up As Ordered demo on the PureMVC website to work out how to do this. They use an extension call the StartupMonitor to to all the initial loading so I’ll be trying to understand that. It seems like it’s a bit more involved than my needs for this project, but it will be worthwhile understanding it for future porjects.
If anyone is reading this with some PureMVC experience please feel free to make comments and point me in the right direction if I’m going off course, it’s all a learning experience so I’ll be glad for the input.