Essential AS 2.0 has a MVC example (in AS 2, of course). In MVC, the model essentially encapsulates the state of the application. The model provides methods that the controller(s) invoke to change the state. The model also handles "system events" that cause a state change (i.e. timer event).
Each controller implements the "business logic" of the application. For example, on a calendar application, clicking the "next" button means go to the next day, week, month, year depending upon the screen. A click on the previous button means similar. There could be 4 controllers (day, week, month, year) each having a "next" and a "previous" function. The controller then invokes a method on the model to cause a state change - Day controller next function could invoke updateDay(+1) on model while the Week controller next function could invoke updateDay(+7) on model. The previous method on same controllers could invoke updateDay(-1) or updateDay(-7). After a change in state, the model informs all views of the change in state. The model can include the state change in the notification (model pushes the data out) or the model can require that the view ask for the information (views must pull the data out). The view responds to the notification by updating the presentation to the user (if needed). HTH Jim ________________________________ From: "Mattheis, Erik (MIN - WSW)" <ematth...@webershandwick.com> To: Flash Coders List <flashcoders@chattyfig.figleaf.com> Sent: Thu, March 18, 2010 5:42:42 PM Subject: RE: [Flashcoders] bubbling listening I've been thinking about the below message from Jason and tried rearranging a simple project into a MVC for a while this afternoon, but couldn't figure out how to do it without breaking encapsulation. I think I'm not getting the MVC advantage because I don't understand one of two things - or maybe something else: The controller listens to an event from the model, how does the controller inform the view to react without a) breaking encapsulation or b)dispatching another event the view is listening for. In b it would seem better to me to have the view listen to the model directly. I tried it both with the controller being the document class and not. Help? Is there a simple example someone can point me to? _ _ _ Erik Mattheis Senior Web Developer Minneapolis T 952 346 6610 C 612 377 2272 Weber Shandwick Advocacy starts here. PRWeek Global Agency Report Card 2009 - Gold Medal Winner The Holmes Report Global Agency of the Year PR News Agency of the Year -----Original Message----- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Merrill, Jason Sent: Thursday, March 18, 2010 9:51 AM To: Flash Coders List Subject: RE: [Flashcoders] bubbling listening Well, that's OK and you don't even have to get fancy yet - just write a class that has references to all the display objects, and listens to your custom events. It also has the handlers in it to respond to the events. This in effect, is a "controller" class. Jason Merrill _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders