XML onLoad Function In Class File

I am trying to write a class to load in an XML file.

I need to figure out how to make the XML.onLoad(success) function call the next function in the class body. For some reason, the function call to traceXML(); in the onLoad function of XML cannot find the traceXML(); function in the class body.

When I instantiate the class at runtime, the trace function inside of traceXML(); never gets ran, even though there is a reference to the traceXML(); function in the onLoad of the XML file. Can anyone tell what’s wrong with my code?

I know that the XML file is loading correctly because “xml is in” is traced to the output panel at runtime. Does the onLoad function not know the path to the traceXML() function?

class XMLIn {
	// Define variables
	public var XMLFile:XML;


	// Constructor
	function XMLIn(file) {
		XMLFile = new XML();
		XMLFile.ignoreWhite = true;
		XMLFile.onLoad = function(success) {
			if (success) {
				trace("xml is in");
				traceXML();
			} else {
				trace("error");
			}
		};
		XMLFile.load(file);
	}
	// function that is supposed to be called within the onLoad of XMLFile
	// but nothing is ever traced to the output panel
	function traceXML() {
		trace("traceXML(); has been ran");
		trace(XMLFile);

	}
}

code in frame 1 of fla file:

var XMLLoad = new XMLIn("layout.xml");