Archive

Archive for October, 2009

MVC Pattern in AS3

October 31st, 2009

Just some random thoughts this morning, following a discussion with a colleague at work.

Perhaps it gets overused, and sometimes abused, but I find the MVC pattern a rather useful way of dividing up code.  By using the pattern, I formalize what I would otherwise try to do anyway: separate my data from the graphical display, and make it easy to switch different views for the same data.  And although with MVC you should be able to set up your data model so the actual data can take several forms, XML is so easy to parse with e4x that it’s really not worth the effort to create a separate class to act as a parser.   So now I think I will call the data “model” the XML format itself.  This does mean, however, that if data is actually stored in some other way, say in the database, a serializer will need to be created to generate this data model.  This way the View in MVC can just parse the data format directly.  The Controller’s role is usually limited to locating the xml file and instantiating the View, passing it the xml.

Or I could just wing it…

admin Actionscript 3.0, Flash CS4 ,