Event Reuse
There are times where you need one event to perform the behavior of another event you already have. In this case you have two choices: One, called context.dispatchEvent from your event handler and throw the new GEMVC Event or two, inherit from a base event, overriding the behavior where necessary. While case one is probably the cleaner way in terms of decoupling and is what is used when you want a higher level controller to handle a portion of an event a lower controller is handling, sometimes due to asynchronous nature of Flex you need to perform an action immediately before do anything else. In this case you just need to inherit the event you want to share and override its handleEvent method or any other methods it may have. You can then substitute your own handlers if the you make service layer calls. Since it is impossible to guess at what events someone may want to extend it is a good idea to code your GEMVC Events in such as way as they can be easily extended. This means that your variables and methods should be in the protected scope and your constructor should be designed to accept any event type string. The following code snippet shows how to set up your constructor:
public class ResetSelectedNodeEvent extends Event implements MVCEvent
{
public static const RESET_SELECTED_NODE:String = "RESETSELECTEDNODE";
protected var _pane:String;
protected var globalApp:MELApplication = MELApplication(Application.application);
protected var model:MELModel = MELModel(MELApplication(Application.application).model);
public function ResetSelectedNodeEvent(pane:String='',type:String=RESET_SELECTED_NODE):void
{
super(type, true, false);
_pane = pane;
}
By adding a type parameter, an extended event can supply its own event identifier but since it is optional, users of the base event do not have to change anything.
