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


On Sun, Jan 17, 2010 at 5:30 AM, Tim Romano <[email protected]> wrote:

>
>
> Let's say I have a class MYHTTPSERVICEBASE which extends
> mx.rpc.http.HTTPService. This base class of mine checks whether it is
> being run in debug mode or release, and sets the base URL to localhost
> or the remote host. Then I have individual http service classes that
> extend MYHTTPSERVICEBASE.
>
> I want my http service layer to dispatch messages that my GUI layer will
> be listening for:
>
> 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 {
> // Got Data? then instantiate and dispatch a bubbling event
> object that encapsulates the data
> // the GUI layer will be listening for this event
> }
>
> Questions:
> Can the event object be dispatched from within the MYHTTPSERVICEBASE?
> Will the GUI hear it if it's dispatched from the base class?
>
> In a class that extends MYHTTPSERVICEBASE, can I override the onResult()
> method that has been registered with the Responder by the base class?
>
> Thanks for the help!
>
>  
>

Reply via email to