Usually I let the view detail the event handlers, which in turn call the
appropriate controller methods. In this case, each view would have something
like
private function saveButton_clickHandler(event:MouseEvent):void{
this.controller.save(/*here is the differing parameter*/);
}
Where the controller might have:
public function save( pathToFile:String ):void{
// do some Savin' based on that parameter
}
This is tidiest, and also makes all calls into the controller synchronous and
stack-traceable.
The business logic of what to do with the parameter naturally belongs in the
controller.
I could understand thinking to have controller methods added as listeners to
view events, but I like my controller methods to have signatures based directly
on what they do, using typed arguments with descriptive names and leave the
event binding to view code.
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:25 PM, "Mattheis, Erik (MIN-WSW)"
<[email protected]> wrote:
> 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
> P: (952) 346.6610
> M: (612) 377.2272
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders