Thank you, Aaron, for the helpful answers. My intention would be to have each of the descendants of MYHTTPSERVICEBASE point to a different destination and raise an event specific to that destination, and to have a separate listeners for each kind of event. If I've understood you correctly, there is no need for each of the descendants to instantiate their own Responder and no requirement for them to override the base execute() method too.

Tim

/* this method is in the descendant class and overrides the base method */
private overrides function onResult(e:ResultEvent, token:Object=null):void {
       // raise a specific event
  }

/* these two methods are in the base class */
    public    function execute() : void {
            myResponder = new AsyncResponder(onResult, onFault);
            this.resultFormat= HTTPService.RESULT_FORMAT_TEXT;
            var token:  AsyncToken = this.send();
            token.addResponder(myResponder);
        }

private    function onResult(e:ResultEvent, token:Object=null):void {
   // this method is overridden by descendants
  }



On 1/17/2010 3:38 PM, Aaron Hardy wrote:

I'll take a crack at it.

Can the event object be dispatched from within the MYHTTPSERVICEBASE?
Sure. I think there may be a separate underlying question here though. Are you asking how? Maybe you can clarify?

Will the GUI hear it if it's dispatched from the base class?
First of all, if the service classes you're talking about aren't on a display list (it's very likely they are NOT) then an event doesn't bubble in the traditional sense. Nothing will hear the event unless it specifically has added an event listener to your service object. So if you want any view component to hear the event being dispatched by your service object, the view component will need to add an event listener to your service object. Depending on the framework you're using, there may be some other mechanism whereby the view can hear about a command's completion. Something else you can do (though some architecture developers will cringe) is dispatch the event off the stage, the system manager, or the base application from your command and then the view would add an event listener to whichever object that is.

In a class that extends MYHTTPSERVICEBASE, can I override the onResult() method that has been registered with the Responder by the base class? Yes. In the case of your sample code, if you override onResult in your class that extends MYHTTPSERVICEBASE, it is the overriding function that is passed into the responder. That is, when you reference onResult, you're referencing the "most extended" onResult function, not just the onResult function in the class from which onResult is referenced.

I hope that makes sense. It's very likely I misinterpreted your questions.

Aaron



Reply via email to