Skip to main content
Inspiring
January 18, 2013
Question

Can anyone take me in step by step to understand MVC design pattern

  • January 18, 2013
  • 1 reply
  • 621 views

Hi Everybody,

I just killed myself trying to understand what is MVC and how to apply it to flash (AS3) the easy way but I could not, there is a lot of information on MVC on google but it is very hard I can not understand it and apply it to anykind of application or game, I had created a lot of games but using flash timeline (puzzle, multipel choice, simple physics interaction) and I understand that we must separte the design interface and the data of the application and the code into diffrent blocks, but what I understand is:

1- making a SWC for the design. (View)

2- use XML or TEXT file for the data.(Model)

3- classes for the code.(Controller)

this is MVC that I understand, but all the tutorials on the net is about creating 3 classes and calling each other in a very diffuclt code to understand, I realy need to work the proffessional way but it is very hard and far away from my understanding.

if any body have a way to let me understand it like making a template for every MVC application or game and explain to me his/her code it will be great, some of my questions are:

1- how we say about a class that it is the view part of the pattern while we have a SWC that hold the intreface graphics?

2- dose making a sepreate class to load and fetch external data sources like xml and text means I had created the model part of the pattern, and why the tutorials on the net do not say that if it is true?

3- making the logic of the application or game sepreated into class for each logic block, makes the controller part of the pattern?

I realy do not know what to ask more because I do not understand the MVC design pattern

Please note: if someone can chat with me on skype it will be great, but if you want to explain here also good but I need to understand it is making me crazy!

thanks in advance

This topic has been closed for replies.

1 reply

Inspiring
January 18, 2013

I'm not a pro in this either, but a few things about it make sense to me.

First you don't need to have only three parts, but all the parts you have should be one of the three things (maybe). And they don't need to be a swc, XML/text, or a class.

I recommend the Clock tutorial from Colin Moock's book, Essential Actionscript.And here is someone walking you through it. http://flylib.com/books/en/4.14.1.137/1/

In that example there is a model which keeps track of time like the hours, minutes, seconds, if the clock is running.

There is a controller that lets you set the time, reset the clock, stop the clock, that kind of stuff. This isn't the buttons and stuff that allow you to do that, this is the code that takes the input from the buttons and communicates with the model.

So there would be a view of the buttons that the user would want to push to set the clock or what have you.

And there is a view presenting the time. Now there might be two (or more views). For example you might have an analog clock and a digital clock.

Work through that tutorial. It helped me.

Inspiring
January 18, 2013

this is very hard for me, can you help me with simple MVC Template for an application that do the following:

1- interface a button that is its design taking from a swc (remmber I need it on flash not flash builder),(this could be the view as i unberstand)

2- a text field that when you click the button it writes in it "Hello MVC". (the text filed is another view i think and this could the controller I think)

3- the Hello MVC text is stored in a variable. (this could be the model i think although i do not know why we need to make a seperat class for it but may be if there more variables it would be resenobale but lets stick with one variable)

but please keep it simple and direct to the point with comments and trace statements if possible?

is it possible?

thanks in advance Rothrock