Tuesday, February 10, 2009

ActionScript 3 - Model View Controller (MVC)

Click to view the video in a pop-up. Right-click and "save as" to download the video to your hard drive.

Watch Video Tutorial on Model View Controller

29 comments:

  1. Good idea to publish this here!! Thanks a lot

    ReplyDelete
  2. Looking forward to watching this but the video is down, why not upload it to YouTube?

    ReplyDelete
  3. John Lindquist2:40 AM

    Are you sure the video is down? Is anyone else experiencing this?

    ReplyDelete
  4. Nice tutorial. Very well done.

    ReplyDelete
  5. Odrakir7:57 PM

    I can see it.

    I don't know why, but for me it feels more "safe" not to pass references from one class to another and use listeners created in the main class application (in this case).

    That way I could have several controllers or several views and make them all pass through a single function when updated, so they are easier to controll.

    But maybe I'm not talking about MVC... I'm not an expert in patterns.

    ReplyDelete
  6. Matt Newell12:21 PM

    Great video can't wait for part 2.

    ReplyDelete
  7. Hey. Great video! Is there any chance you can release the source code? The video is simple enough to follow but it would be quicker to check the source code instead of watching the video again to better understand the concepts.
    Cheers.

    ReplyDelete
  8. Hendrik Lammers11:56 PM

    Thnx!!

    ReplyDelete
  9. ookla7:23 AM

    dude, that is a shame that I don't have cash on paypal.. really really thanks!

    ReplyDelete
  10. Karl Macklin2:05 PM

    Looking forward to another part explaining benefits and such.

    I don't know much about MVC but I thought the idea was to decouple the view and model, and have the controller act as a mediator between them.
    As it is right now, the view knows about the model, no?

    I am certain there a huge benefits with MVC as a design pattern, but at the end of this video I can't help but think "ok so now it's more tedious to set up a interactive function for example".

    I tried getting into MVC and Cairngorn a while back but got stumped by the difficulty of it.

    In any case, these kind of videos are always helpful. I plan to starting up some of my own. Gotta set up a blog first.

    ReplyDelete
  11. Thanks a lot John! This video is very insightful - even if its still kinda over my head at the moment! But I think after a few times watching it will be clearer. Its great just to watch a real coder in action as well!

    This site is a goldmine resource for learning :)

    ReplyDelete
  12. George1:44 PM

    Thank you that really helped explain the MVC comment, plus i picked up on some basic Flex tips.

    Thanks!

    ReplyDelete
  13. Jian Wu2:31 PM

    hi,I love as3 develop,can you teach me,tks

    ReplyDelete
  14. Marian8:28 AM

    this is a really good tutorial. Thanks

    ReplyDelete
  15. And what about dispatchEvent from model. What if i will give listener in controller and he will comunicate to View. It is bad thing? thanks

    ReplyDelete
  16. do you seriously code in MVC? As an architect of many years, including 7 in flash, I think I have QA'd just about every possible disaster scenario, many of which come about from applying traditional coding paradigms to areas where they just over complicate matters. In the case of flash, I have come into supposed OOP projects quite a few times with MVC or other design patterns, 6 thousand classes and not a whit of documentation to tie it together. The answer is of course good documentation on differing levels. Although I will admit that MVC is a good way to ensure the client never uses another coder.

    ReplyDelete
  17. Thanks, please do the second video on why do we used MVC

    ReplyDelete
  18. Laika3:05 PM

    Hi !
    Thanks a lot for this video, can't wait for the part 2 !!

    ReplyDelete
  19. John Lindquist1:43 PM

    @labcoat - Thanks for pointing that out. Definitely a slip-up on my part when putting together my example. If I find the time, I'll update the example and have the controller add the listeners to the view.

    ReplyDelete
  20. Santosh(laaptu)6:51 PM

    Thanks a lot John.This video means a lot to me

    ReplyDelete
  21. Kerry1:18 AM

    @labcoat - I'm at the very beginning stages of understanding design patterns and so I've been looking up many resources. One I've come across is an excerpt from the AS3 Design Patterns book from O'Reilly (which can be viewed at http://www.adobe.com/devnet/actionscript/articles/ora_as3_design_patterns/ora_as3_design_patterns_ch12.pdf). It lists each views "knowledge" of other views a bit differently and I think more inline with what John's video was saying.

    It says that:
    -the model needs a reference to the views
    -the view needs a reference to both the controller and the model and
    -the controller needs a reference to the model

    It describes the communication between the different parts after a simple button click like so:

    "The sequence of events is represented
    as follows:
    1. User interacts with a user interface element (e.g. clicks on a button in a view).
    2. The view sends the click event to the controller to decide how to handle it.
    3. The controller changes the model based on how it decides to handle the button
    click.
    4. The model informs the view that the state of the model has now changed.
    5. The view reads state information from the model and updates itself."

    @John - Thanks for the videos!

    ReplyDelete
  22. John Lindquist2:36 AM

    The great thing about design patterns is that they teach you best practices on how to keep your code clean and separated. In real-world situations, you use them as guidelines instead of rules.

    ReplyDelete
  23. Kerry4:40 AM

    Then you don't have to redo your video =)

    ReplyDelete
  24. Really good tutorial. I've been looking at different design practices to incorporate into the projects I do at work. MVC looks like the best way to go in separating game logic, data logic and the display.

    ReplyDelete
  25. Looks like the video is down :(

    ReplyDelete
  26. John Lindquist1:11 AM

    The video is back up.

    ReplyDelete
  27. Clark Cookie6:38 AM

    hi John, any chance you can do the robot legs equivalent of this tutorial? i found it really useful in understanding MVC and assume it would do the same if you did this exact example using Robot legs
    thanks. Clark

    ReplyDelete
  28. rimacy7:36 PM

    This tut was informative and easy to listen to . i was thankful for the simple application. I wasn't distracted from the material by new extraneous concepts. Thanks for giving me a start with MCV. I'm also stronger now in event dispatching. I was looking for the follow up video where you talk more about the power of this model. If it exits(or if it doesn't) i would be glad to know about it.

    Thanks Again John

    Rob

    ReplyDelete
  29. Slowsay1:11 AM

    Excuse me, would like to ask about pv3d how to delete, it will not increase the memory consumption

    ReplyDelete