[OOP 2.0] Help Calling Functions within Class Definitions

Hey all,

This seems like it would be really easy but for some reason it’s not working.

I have a class file, class DataSet, which right now only takes an XML file, parses it, and pushes the XML into an array:

The object is instantiated and an XML file is passed back to the object definition. If the XML file is successfully loaded, the class should then called the function parseXML() and put the data into the array.

But for some reason, parseXML() is never called. I have no idea why this isn’t working, because the syntax checks out and I’ve seen millions of other files where functions call other functions.

Here’s the class file:


class DataSet {

	private var arrDataSet:Array = new Array();
	
	public function DataSet() {
	};
	
	public function init(dsName:String, dsXML):Void {
		trace("made a dataset called " + dsName);
		trace("will attempt to handle " + dsXML);
		
		var theXML:XML = new XML();
		theXML.ignoreWhite = true;
		theXML.onLoad = function(success:Boolean) {
			if (success) {
				if (this.status == 0) {
					trace("XML worked! Parsing XML...");
					parseXML(this);
				}
				else {
					trace("Error parsing XML. Error code: " + this.status);
				};
			} else {
				trace("Error locating XML file.");
			};
		};
		theXML.load(dsXML);
	};
	
	/* WHY DOESN'T IT CALL ME */
	private function parseXML(loadedXML:XMLNode) {
		var datasetNode:XMLNode;
		for (var i:Number = 0; i < loadedXML.firstChild.childNodes.length; i++) {
			datasetNode = loadedXML.childNodes[0].childNodes*.attributes.name;
			trace("Node " + i + ": " + datasetNode);
			arrDataSet.push(loadedXML.childNodes[0].childNodes*.attributes.name);
			trace("pushed! arrDataSet now says: " + arrDataSet*);
		};
		trace("Finished parsing!!");
		trace("arrDataSet is this big: " + arrDataSet.length);
	};

};

Here’s the code in my .fla:


var dsTest:DataSet = new DataSet();
dsTest.init("dsTest", "test.xml");

Here’s what my trace statement says:


made a dataset called dsTest
will attempt to handle test.xml
XML worked! Parsing XML...

Thanks in advance for any help you can give me!