Variable value not passing to clipEvent

Frame1:

stop();
loadText = new LoadVars();
loadText.load("gallery.txt");
loadText.onLoad = function(success) {
 _global.total = this.total;
 trace(_global.total);
 gotoAndStop(2);
};

Frame2:

stop();
MovieClip.prototype.tot = total;
MovieClip.prototype.i = tot/2;
MovieClip.prototype.j = i;
MovieClip.prototype.num = tot;

Attached on a mc (within a mc):

onClipEvent (load) {
 this._visible = 0;
}
onClipEvent (enterFrame) {
 //CODE GENERAZIONE QUARDATI
 trace(tot);
 for (var i = 1; i<tot+1; i++) {
  e = "foto"+i;
  if (i%2 != 0) {
   if (i != 1 && i != 2) {
    yp = 0;
    xp = _parent["foto"+String(i-2)]._x+68;
   } else {
    xp = 0;
    yp = 0;
   }
  } else {
   if (i != 1 && i != 2) {
    yp = 68;
    xp = _parent["foto"+String(i-2)]._x+68;
   } else {
    yp = 68;
    xp = 0;
   }
  }
  duplicateMovieClip(_parent.foto, e, i);
  _parent[e]._x = xp;
  _parent[e]._y = yp;
  _parent[e].img._xscale = 64;
  _parent[e].img._yscale = 64;
  _parent[e].foto.n.text = i;
  _parent[e].dataa = dataa*;
  _parent[e].link = link*;
 }
}

What it does (should do) basicaly is duplicate the mc foto for the value of tot.
The txt file is loaded properly and it does trace the correct value for total and tot but it doesn’t duplicate the movie.
If instead of

MovieClip.prototype.tot = total;

I write

MovieClip.prototype.tot = 10;

Everything works fine.
Any idea why if tot and total trace the right value, the duplicateMovieClip won’t work???:-/