Extending HTTPService

Hi,

I have written a class NoCacheService that extends the HTTPService class.
It has two features: it foils browser caching by making each url unique, and it provides a default fault handler.

The class is written in AS-3, but is instantiated from .mxml files.
The nocaching part is working fine, but the fault handling does not work.
I am new to AS-3 and Flex-3, and hope someone can spot the errors.

Here’s an example of using the class in a .mxml file:

<utils:NoCacheService
id=“httpHaltTask”
url="{Session.flexRoot}{Constants.URL_HALT_TASK}"
resultFormat=“e4x”
showBusyCursor=“true”
concurrency=“single”
result=“resultHaltTask(event)”
fault=“faultHaltTask(event)” />

This example works fine, except for 2 bugs: I can’t seem to access either the id property or the fault property, so the default fault handler gets used (instead of the specified one), and the error messages don’t show the id of “httpHaltTask”.

Here’s the class from the action-script file:

package rsc.components.utils {
import mx.rpc.AsyncToken;
import mx.rpc.events.FaultEvent;
import mx.rpc.http.mxml.HTTPService;

public class NoCacheService extends HTTPService {

public function NoCacheService(rootURL:String=null, destination:String=null) {
  super(rootURL, destination);
  
  // if no fault property in the mxml declaration, add one here
  // ConsoleBox.addStr is similar to trace()
  if (!this.hasEventListener(FaultEvent.FAULT)) {
    //ConsoleBox.addStr("adding fault handler to " + String(this));
    this.addEventListener(FaultEvent.FAULT, defaultFaultHandler);
  }
  else ConsoleBox.addStr("keeping fault handler" + String(this));
}

override public function send(parameters:Object = null):AsyncToken {
  if (parameters == null) parameters = new Object();
  parameters.nocache = String(new Date().time);
  //ConsoleBox.addStr(sprintf("%s/%s",this.rootURL,this.destination));
  return super.send(parameters);    
}

private function defaultFaultHandler(event:FaultEvent):void {
  ConsoleBox.addFault(String(this),event);
}

}
}

So the this.id reference doesn’t work, and the test this.hasEventListener(FaultEvent.FAULT) doesn’t work.
What should I replace them with?

Thanks!