I'm wondering what would be considered best practise for this. It's fairly inconsequential but I'm interested in peoples opinions.
We have two classes - TitleBar and TemplateMain. TitleBar is a bar at the top of the screen that displays the project title and several buttons (settings, print, fullscreen, etc) that the TemplateMain will need to listen to in order to run the relevant functions. At the moment, the Template listens for the click mouseevent and then uses a switch statement to get the initial target of the event, eg:
protected function onTitleBarClick(e:MouseEvent):void {
switch (e.target){
case (titleBar.settingsButton):
addSettings();
break;
// etc..
}
}
Would there be any advantage or is it desirable to port this into a custom event system, either extending the native Event class or maybe even as3signals so that the titlebar itself has the click listener and then dispatches an event that TemplateMain picks up and then acts accordingly? One negative of this I can see is that, along with mouse click listener, I'd end up with another six listeners for the custom events.
Like I said, maybe it doesn't matter but I'd like to know how others handle this very common situation.