View Full Version : Flex 4:Retrieving the action from the ResultEvent in an event handler

02-09-2011, 05:33 PM
I have been using Flex(Flash) Builder 4 now for a little while. It used to be that, when importing web services, fault and result event types were created for each web service in the suite of services supplied by the provider.

In Flex 4, however, these events are not created and you use the generic ResultEvent and FaultEvent. I can see how this may be more efficient but this can lead to a problem.

private var __mywstest:ProviderServices = new __mywstest:ProviderServices();
__mywstest.addEventListener(ResultEvent.RESULT, mywstestResultEventHandler);

private function mywstestResultEventHandler(_e:ResultEvent)

So far, it is fine, but the format of the result returned from a call to testMethod1 may be different to that returned from testMethod2. So how do you distinguish which method has triggered this resultEvent?

The only way I have figured out how to do this is to write the following function. You pass it the resultEvent and it returns a string containing the name of the call that triggered this handler.

private function getActionFromResultEvent(_e:ResultEvent):String
var _actionArray:Array = _e.token.message["httpHeaders"].SOAPAction.split("#");
return _actionArray[_actionArray.length-1].split("\"")[0];

This works, but is there a more conventional way to access this information, that I may have overlooked?

04-11-2011, 06:23 PM
did you ever get an answer to that? there MUST be a batter way, surely...?