0

I am using RemoteObjects to call ZendAMF PHP from Flex/Flash Builder 4.6. I want to stop or abort a method call before it sends the request to the server based on an event or similar.

I have a class where I create and store all the RemoteObjects - for example:

activityLogService = new RemoteObject("zend");
activityLogService.endpoint=endpointServer;
activityLogService.addEventListener(FaultEvent.FAULT,faultHandler);

Then later I can simply call this object:

remotingService.activityLogService .getRecords();

I am trying to find a way in my remotingService object to stop the request - and not send anything to the server - for example if some variables are not set properly.

I noticed there is an invoke event: activityLogService.addEventListener(InvokeEvent.INVOKE,invokeHandler);

However, I can not tell if that's going to stop things at the proper point, or if it's even possible to actually STOP the request - if so, how?

Thanks!

Scott Szretter
  • 3,938
  • 11
  • 57
  • 76

1 Answers1

0

Check out this question Flex : Is it possible to stop a remote call?

If you're using a RemoteObject you should be able to call getOperation() method and then cancel() on the corresponding operation.

Community
  • 1
  • 1
JeffryHouser
  • 39,401
  • 4
  • 38
  • 59
  • That's close, but what I am looking for is to block the operation before it is able to send anything. I think with what you are suggesting the getOperation would potentially start to connect and could even complete before a cancel() is called? – Scott Szretter Feb 28 '12 at 20:23
  • 1
    If you want to cancel something before it starts; why don't you just set a Boolean flag (AKA CallService) and then check that flag before initiating the call? (if CallService == true){ remoteObject.send() } – JeffryHouser Feb 28 '12 at 20:57
  • your answer is intriguing, but I am not completely sure what you mean - for example, when I call: remotingService.activityLogService.getRecords(); ".getRecords()" is the remote method on the php side. So I am not sure where I would on the flex side put the if() part. – Scott Szretter Mar 24 '12 at 13:16
  • @ScottSzretter I'm not sure which "IF()" part you're referring to; as I don't make mention of any conditionals in this answer nor the one I linked to. – JeffryHouser Mar 24 '12 at 16:41
  • (if CallService == true) in your comment – Scott Szretter Mar 25 '12 at 16:36
  • @ScottSzretter Oh, I get it. You'd wrap the call in an if; like this if(callService == true) { ( remotingService.activityLogService.getRecords()) } – JeffryHouser Mar 25 '12 at 22:35