Flash 8 introduced a new "feature" whereby EventDispatcher handles events named "load", "draw", and "move" differently. This broke the previous version of the XML2 class, which dispatches "load" events. I have updated it to use a "complete" event instead - it's a little less intuitive perhaps, but it works. I've also added support for a "httpStatus" (F8 only) event, as well as adding some missing typing on method params.

For those unfamiliar with XML2, it is a simple extension of the built in XML class that provides:
  • AS2 friendly EventDispatcher style event handling (addEventListener)
  • Load timeout functionality
It's API looks like so:
Constructor:
myXML2 = new XML2([xmlString:String]);
  • xmlString - optional parameter specifying an XML string to parse
Properties:
Inherits all properties from XML, and adds:
  • connectionTimeout - specifies a maximum time in milliseconds to begin receiving XML data from the server. If no data is received within this period, a "complete" event will be fired with a success value of false, and the status property will be set to -101.
  • timeout - specifies a maximum time in milliseconds to finish receiving all XML data from the server. If the load is not completed within this period, a "complete" event will be fired with a success value of false, and the status property will be set to -100.
Methods:
Inherits all methods from XML, and adds standard event dispatcher methods (addEventListener, removeEventListener). Events:
XML2 removes the XML handlers (onLoad, onHTTPStatus) in favour of EventDispatcher events. The supported events are:
  • complete - dispatched when the XML has been fully loaded and parsed, or an error occurs (ex. a timeout). Event object includes a boolean "success" property.
  • httpStatus - (Flash Player 8 only) dispatched when the httpStatus is received (see XML.onHTTPStatus for details). Event object includes a numeric "httpStatus" property containing the status of the http request (ex. 404 - not found).
Here's the XML2 example updated:
// import the class
import com.gskinner.net.XML2;

myXML = new XML2();

// subscribe to its load event:
myXML.addEventListener("complete",this);

// subscribe to its httpStatus event:
myXML.addEventListener("httpStatus",this);

// set the connection timeout period to 3 seconds (default is 7s):
// (ie. data must begin loading within 3 seconds):
myXML.connectionTimeout = 3000;

// set the timeout period to 10 seconds
// (ie. all data must be loaded within 10 seconds):
myXML.timeout = 10000;

// this should timeout after 3 seconds:
myXML.load("http://1.1.1.1/nofile.xml");

// function to handle the complete event:
function complete(p_evtObj:Object):Void {
   var XMLObj:XML2 = p_evtObj.target;
   trace("success: "+p_evtObj.success);
   trace("status: "+XMLObj.status);
   trace("toString: "+XMLObj.toString());
}

// function to handle the httpStatus event:
function httpStatus(p_evtObj:Object):Void {
   trace("http status: "+p_evtObj.httpStatus);
}
You can download XML2 by clicking here.