Again with highestDepth prototype!

I’ve been struggling with this for some time now and I just can’t figure out why one of these scripts works and the other doesn’t. Any help would be great and much needed!

I am creating dynamic text fields from an xml file and I have to publish for player 6, so I can’t use getNextHighestDepth. I have the prototype that can be used instead, but it only works in this first script:


MovieClip.prototype.highestDepth = function() {
  
	var curr, high = undefined;
	for (var clip in this) {
		if (!isNaN(curr=this[clip].getDepth()) && this[clip]._parent == this) {
			if (curr>high || high == undefined) {
				high = curr;
			}
		}
	}
	return high+1;
};

for (var i = 0; i<10; i++) {
	mytext1 = " mytext1 "+i;
	mytext2 = " mytext2 "+i;
	createTextField(mytext1, this.highestDepth(), 0, i*20, 220, 100);
	trace(this.highestDepth());
	with (eval(mytext1)) {
		text = "text1";
	}
	createTextField(mytext2, this.highestDepth(), 50, i*20, 220, 100);
	with (eval(mytext2)) {
		text = "text2";
	}
}


However when I use it like this, it doesn’t even seem to call the prototype.

 
MovieClip.prototype.highestDepth = function() {
   
	var curr, high = undefined;
	for (var clip in this) {
		if (!isNaN(curr=this[clip].getDepth()) && this[clip]._parent == this) {
			if (curr>high || high == undefined) {
				high = curr;
			}
		}
	}
	return high+1;
};

xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("myFile.xml");

function loadXML(loaded) {
	if (loaded) {
		myXML = this.firstChild.childNodes;
		for (var i = 0; i<myXML.length; i++) {
			text1 = "text1"+i;
			text2 = "text2"+i;
			createTextField(text1, this.highestDepth(), 0, 20*i, 220, 100);
			with (eval(text1)) {
			   text = this.firstChild.childNodes*.childNodes[1].firstChild.nodeValue;
			}
			createTextField(text2, this.highestDepth(), 80, 25*i, 220, 100);
			with (eval(text2)) {
				text = "text2";
			}
}}}


Thank you!