Andy Van Dam and his student, Sascha, came to my office and gave me a signed copy of "Computer Graphics". As Napoleon Dynamite would say, "Yesssss!"
I was inspired by Avalon and the wizardly developers at work to try a different approach in Actionscript programming. Rather than associating classes to movielip symbols, I am writing Model, View, and Control classes that do not involve movieclips at all. Movieclips are merely compositional elements on top of the View layer. As a UI platform, the movieclip architecture is flawed; treating movieclips as raw fodder for a UI element's control class could work around Flash's limitations. New opportunities would include serialization of ui objects, true separation between code and graphics, and [other stuff]. There are performance issues, so this approach might be nothing more than an exercise.
On a side note, Chafic tells me he's already doing this, so I am not as smart as I thought ;-)
-Sam
Posted by samuel at August 24, 2004 12:50 PMGotta admit though, I tend to not seperate the controller from the view that often.. I like having an ApplicationController and then end up with M + (V+c). Small c since the controller's role is so minor. Also these days my (V+c) is usually just a sub-class of UIComponent. I would be interested to know how many people really build seperate M+V+C everywhere.
Posted by: Chafic Kazoun at August 24, 2004 02:03 PMsame as chafic, I hardly ever have a reason to separate view/controller (more used to model/ui delegate)... i am however still stuck with thinking of my UI as a movieclip (or an extension of it thereof), as there really isn't anyway of escaping this, and the "true separation" you allude to never really happens... for simple things it might appear to be so, but as you start dealing with more resources/movieclips within other movieclips (subatomic views within other views, if u may) it becomes apparent that all your movieclip compositional elements really just introduce a needless layer of references
- eokyere
Posted by: Emmanuel Okyere at August 24, 2004 02:53 PMSame here. I think this type of structure is so common in Flash because of the example set by both V1 and V2 component frameworks.
Posted by: Peter Hall at August 24, 2004 03:13 PManother alternative to MVC approach is the visual proxy architecture, adapted off course for ActionScript and MovieClip.
http://www.javaworld.com/javaworld/jw-09-1999/jw-09-toolbox.html
using __resolve to bind a model (instance) to a view(movieclip) is a way to have a visual proxy which not proxy(ise?) graphics message (as in the Java article) but the instance scope,
in fact it's work as the fusion of 2 instances acting as 1 instance.
And combined with prototype-based philosophy it can be very powerfull, cf this paper:
http://www.google.fr/search?q=cache:eOkewNa-DngJ:wsmith.best.vwh.net/OOPSLA95.pdf+prototype%2Bbased+visual+interface&hl=fr
or for the PDF:
http://wsmith.best.vwh.net/OOPSLA95.pdf
cheers ;)
I tend to separate them all, especially with remoting applications where the M is on the server (acting as the delivery agent).
I usually have a Main MC on stage that is bound to my main controller class, the different Views of the application have their associated classes and then I use EventDispatcher to make calls to the controller who will either use other controller classes I have defined or relay information to the Model and then update the view.
Posted by: Will at August 24, 2004 04:59 PMSeveral reasons for pure separation (or, what life would be like without movieclips):
1. Layout - Flex has some nice layout going on. How can you reparent a UI element that extends Movieclip? You can't. You have to serialize the UI object so that it's independent of the movieclip architecture (which i am trying to escape).
2. Multiple windows - again, serialization of the object and its states would allow you to move a UI element from one flash window to another... even to popups.
3. Platform independence - I've seen several publicly known language -> swf compilers, such as Rebol (www.rebol.com), which treat the flash player as one of several possible presentation layers. I think the open source gui toolkits aspire to this as well, though I don't know them very well.
4. Customization - both code-driven rendering of UI elements within the control class as well as coupling of graphical symbols (movieclips, manually drawn vectors, etc.) seriously limit the flexibility of the class design.
Of course, this all takes a lot of up-front work that nobody in the community has time to do. Maybe Flex already has a completely different framework that's not hobbled by movieclips, but I see it as a major obstacle within Flash.
Posted by: Sam at August 26, 2004 01:56 PMI would be interested to know how many people really build seperate M+V+C everywhere.
Sound Recorder
Buy Computer
Cialis makes intimate and satisfying love possible!
http://www.cialismagic.com
It's interesting how spam can make it past the captcha plugin. How profitable can it be for a spammer to manually input spam comments into individual blog posts? Could this be the recently documented sweat-shop spam attack, where spammers engage in sweat-shop labor practices to employ large numbers of people to spam websites, subscribe to free email accounts, earn Everquest items, etc?
Posted by: Samuel Wan at September 2, 2004 11:21 PM