I am using this code on the first frame:

preloadbar_mc.onEnterFrame = function(){
if (!this.target) return (0);
var loaded = target.getBytesLoaded();
var total = target.getBytesTotal();

var scale = 0;
if (loaded && total){
var percent = loaded/total;
scale = 100 * percent;
}

this._xscale = scale;
}

preloadbar_mc.target = xmlData;



and this code on the second frame:

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

function loadXML(loaded) {
if (loaded) {
//blah blah blah
...


In some cases I get an undefined error when it loads (but not all the time) does anybody have any suggestions as to why?!?!?!? or see anything wrong with the code?!??!?!

Thanks in advance