Again, a completely different approach to MVC than mine, so you have your pick :)
Ross P. Sclafani Owner / Creative Director Neuromantic Industries http://www.neuromantic.com http://ross.sclafani.net http://www.twitter.com/rosssclafani 347.204.5714 On Mar 15, 2012, at 5:44 PM, "Peter Ginneberge" <p.ginnebe...@telenet.be> wrote: > I usually have Events that match the "data" (for lack of a better word) they > are related with. > > eg: NewsEvent, UserEvent, etc.. > > Events then contain one or more static constants representing different event > types. > > eg: NewsEvent.GET_NEWS, NewsEvent.UPDATE_NEWS, UserEvent.LOGIN, > UserEvent.LOGOUT, etc.. > > Here's one I'm actually using right now: > ============================================= > > public class NewsEvent extends MVCEvent { > > public static const GET_NEWS:String = "getNews"; > public static const UPDATE_NEWS:String = "updateNews"; > public static const ADD_NEWS:String = "addNews"; > public static const DELETE_NEWS:String = "deleteNews"; > > public var data:NewsDTO; > > public function NewsEvent(type:String, dto:NewsDTO=null) { > super(type); > data = dto; > } > > override public function clone():Event { > return new NewsEvent(type, data); > } > > } > > ============================================== > > The controller then maps the different event types to Commands: > // AppController: > > private function initCommands():void { > addCommand(NewsEvent.GET_NEWS, GetNewsCommand); > addCommand(NewsEvent.UPDATE_NEWS, UpdateNewsCommand); > > addCommand(NewsEvent.ADD_NEWS, AddNewsCommand); > addCommand(NewsEvent.DELETE_NEWS, DeleteNewsCommand); > // etc.. > } > > ============================================== > > addCommand (not included) does an addEventListener and maps it to the command > class for later execution (when the event is triggered). > > That's about all the controller does really, listen for events, which are > mapped to commands. > I do reduce the number of event classes by grouping them (NewsEvent has: get, > add, update, delete), > instead of having an AddNewsEvent, GetNewsEvent, UpdateNewsEvent and so on. > > Hope that helps.. do let us know if it doesn't :) > > regards, > Muzak > > > ----- Original Message ----- From: "Mattheis, Erik (MIN-WSW)" > <ematth...@webershandwick.com> > To: "Flash Coders List" <flashcoders@chattyfig.figleaf.com> > Sent: Thursday, March 15, 2012 10:25 PM > Subject: [Flashcoders] Dispatching events from V to C > > > Say I have a "save" button that can exist in multiple views and can save > multiple things. What's the best way to do this? Dispatch a different custom > event from each type of button? Send one type of custom event with different > parameters? I have a controller that listens for 28 different custom events. > I'd like to make the controller class smaller. > > _ _ _ > Erik Mattheis | Weber Shandwick > > _______________________________________________ > 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