Hello :)
To implements MVC or a FrontController in your application you can try to
use the event model of my opensource framework based with the DOM2/3 of the
W3C model events, example :
http://code.google.com/p/vegas/wiki/VegasTutorialsEvents
Vegas page project : http://code.google.com/p/vegas/
Install Vegas : http://code.google.com/p/vegas/wiki/InstallVEGASwithSVN
Tutorial in french to implement Visitor, Observer and FrontController(MVC)
pattern with VEGAS :
http://www.ekameleon.net/blog/index.php?2006/12/13/53--vegas-design-pattern-visitor
http://www.ekameleon.net/blog/index.php?2006/12/16/54--vegas-tutorial-02-design-pattern-mvc-and-observer
http://www.ekameleon.net/blog/index.php?2006/12/22/56--vegas-tutorial-03-design-pattern-mvc-with-frontcontroller
http://www.ekameleon.net/blog/index.php?2006/12/22/57--vegas-tutorial-03-design-pattern-mvc-with-frontcontroller-partie2
you can test this tutorials with the example in the AS2/bin/test/vegas/util
directory of the SVN repository of VEGAS.
To finish i have begin to write a little library based on VEGAS, an
Actionscript Template to creates application with VEGAS :
http://code.google.com/p/astr/
This project is only an opensource example to implements with Vegas a full
application with a global FrontController, MVC , config and localization
model etc... This project is in alpha version but explain the event
implementation of VEGAS.
EKA+ :)
2007/5/3, sebastian <[EMAIL PROTECTED]>:
Hello folks,
My next question is conceptual...
I've made good progress on many of the classes in my application, but
I'm now caught in a dilemma regarding approach.
As mentioned in a previous mail, I'm building a system that can be
divided into two: 1 part does general world 3D animation until the pages
are opened; this was relatively easy to make... the second part of the
system deals with generating pages [its a templating MVC system]; this
is the tough part!
At the center of the application is my class: PageController
Linked to it are 3 other Classes: PageModel [to load new pages],
StatsCollector [to record new pages called] and MouseController [told to
turn off 3D motion when pages are opened].
I was planning on using an object-instance pointer in the PageController
formed during its construction, to tell the associated Classes that a
new event has ocured, but someone pointed out to me that I should be
using an event based system instead [so that's its easier to add new
Classes that listen to the Controller in the future]
Here is what I have:
class com.blabla.PageController {
//Object pointers
private var pageModel:Object;
private var statsCollector:Object;
private var mouseController:Object;
private var urlMapper:Object;
//Page open/close status
private var activeWindow:Boolean;
function PageController (
__pageModel:Object,
__mouseController:Object,
__statsCollector:Object,
__urlMapper:Object)
{
//Pointers:
this.pageModel = __pageModel;
this.statsCollector = __statsCollector;
this.mouseController = __mouseController;
this.urlMapper = __urlMapper;
//Set initial state:
this.activeWindow = false;
}
//this method is called by SWFAddress on url changes:
public function urlChange(__name:String):Void {
// MOUSE CONTROLLER
//set the page active true to turn off
//3D mouse system:
this.activeWindow = true;
//tell 3D mouse system to check status:
this.mouseController.checkWindowStatus();
// PAGE MODEL
//call URL mapper returns an XML file based
//on the url __name
//this XML file is then passed to the pageModel
//which will then notify the PageView of changes
this.pageModel.buildPage (this.urlMapper.convertLink
(__name));
// STATS COLLECTOR
//run the method in 'statscol' with url:
this.statsCollector.callURL(__name);
}
}
So, my question is... is this the right way to be sending events? By
making pointers and calling methods in connected classes? Also, should I
store my "activeWindow" parameter in the Controller? I have a feeling
its in the wrong Class; but from a Code-clarity perspective it does make
sense to have it here as the controller is a state-dispatcher...?
Or should I be using an event based system instead of pointers? If so,
could someone lightly outline what the difference would be like in such
a set up? I'm not very familiar with using events to drive app like
this. I'd be very thankful.
Here is the latest diagram of the system:
http://www.chedal.org/temp/uml_design_03.png
[this that are blue/green are things I've built