PDA

View Full Version : MVC help


ndmccormack
02-29-2008, 05:11 PM
Hi there,

I've been learning AS3 for a month or so now - reading Advanced AS3 by Collin Moock and AS3 with Design Patterns, doing some small projects - and, more or less, it all sorta makes sense.

I'm now going to embark on creating a website for a friend/client on the cheap and I just want to make sure I'm using the correct method for outlining the site.

The site is a standard folio site - Homepage, News, Work, About, Contact. I'll go into a little detail as how the site animates/is constructed.

- The pages are 'stacked' on top of each other, and scroll vertically to the required section when the user interacts with the nav.

- The nav has some fancy interactive wires on it that correspond to each nav option, these animate between sections.

- the work section scrolls horizontally through all the projects - similar to how spin.co.uk works.

- the site is updated via xml.

- I'd like to create a proxy image loader so that the work images load in the bg after the main swf/site has loaded.


Now, I presume that I create a main controller that then loads in the following

Main Controller
- DataLoader ( loads XML, stores data)
- - ImageProxy ( sequentially loads all work images )
- Main View ( stacks other views vertically )
- - progressBarController ( get's loading proogress of site, XML, bg image )
- - - progressBarView ( shows loading progress )
- - Navigation controller
- - - Nav Vie
- - - - Fancy Wires
- - Homepage Controller
- - - Homepage View
- - News Controller
- - - News View
- - Work Controller
- - - Work Model/Data ( pulls images from image proxy )
- - - Work View
- - About Us Controller
- - - About Us View
- - Contact Controller
- - - Contact View


I'm confused as to whether I should have more Models/Data classes, is one enough? once the XML has loaded should I parse the data out into other Data classes - one for each section? I realised that it would be best to have a Work Model class as it is relatively complex.

Am I missing the point of MVC, can I simplify it in other ways?

Any help is much appreciated

Cheers
Niall

Flash Gordon
03-02-2008, 07:41 AM
My basic set up is this...and it isn't MVC. I basically follow 1 rule: 1 purpose for 1 class.

navigation - class
transitions - class
each "scene" - class
sound fx - class

now with in that I may or may not use MVC, but that's my basic structure for the site. The Document Class merely instantiates all the other classes.

yell0wdart
03-05-2008, 08:45 PM
I tend to agree w/ Mr Gordon above. Not MVC specific, but definitely very good practice. You should be able to describe what any of your given classes do in a short sentence. If you find yourself drawing out the description with lots of and's, etc, then it might be time to rethink your design. ;)

With that said, how are you setting this up? What does your class hierarchy look like? I can see the different functions in your list there, but it's hard to make out exactly where you're having problems...

/edit

I'd also argue, that if you're only using one datasource (seems to be XML in your case), then only one model may be necessary. You're just using a singular class to parse through XML text and attributes.