IMO, EventDispatcher will work well in most cases. If you need a more
flexible or scalable way to handle events, then I'd suggest writing your own
event framework based on the Observer pattern as there are some limitations
to EventDispatcher.



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of sebastian
chedal
Sent: Friday, May 04, 2007 5:24 AM
To: [email protected]
Subject: [Flashcoders] Re: AS2: Design Pattern: event based or pointer?
frommodel or controller?

Alo,

So I've done some more independant research,

I think I'm going to use an EventDispatcher system from the PageController:

http://www.adobe.com/devnet/flash/articles/creating_events.html

Instead of pointers. As I think this makes more sense.
Ofcourse, any insight from the 'pros' still welcome!

With kind,

Seb.

On 5/3/07, sebastian <[EMAIL PROTECTED]> wrote:
>
> 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 until now]
>
> Note I chose to connect the MouseController and StatsCollector to the
> PageController instead of the PageModel because if I did so the
> PageModel would get very long in terms of code; I want the PageModel to
> focus JUST on storing the Templates' data that the View will build [by
> refering to the PageModel's loaded data]. Also, if I linked everything
> to the PageModel instead, the functionality of the PageController as a
> dispatcher would be made redundant... am I right in this thinking?
>
> If you wish I can copy-paste the code of other Classes [assuming I've
> written the code!], but I don't think this is necessary to answer my
> question.
>
> With kindness,
>
> Sebastian.
>
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to