Preloader RE-USABLE help PLZ

Hi and Thanks for any help or comment:
How to put my preloader inside a rectangle? and I found that my preloader gets thick when start to growing how can I correct this?

(This preloader can be re-usable in other words you can charge diferent jpeg to the main movie with the same preloader)

// My first TRY but with ERRORS whats WRONG?

//Creo recuadro para la barra pero si entiendo bien debo definir los cuatro puntos para trasar las lineas no? algo asi? 
//lineTo(100,300); 
//lineTo(300,300); 
//lineTo(300,100); 
//lineTo(100,100); 


this.createEmptyMovieClip("totalBar", 2); 
this.totalBar.lineStyle(11, 0x000000,100); 
this.barra.lineTo(250, 0); 


//asi se crea un cuadrado 
//function DibujaRectangulo(x1:Number, y1:Number, width:Number, height:Number) { 
//mc.lineStyle(thick, color); 
// mc.moveTo(x1, y1); 
//mc.lineTo(x1+width, y1); 
//mc.lineTo(x1+width, y1+height); 
//mc.lineTo(x1, y1+height); 
//mc.lineTo(x1, y1); 



// Creamos la barra que indicarĂ¡ el progreso 
this.createEmptyMovieClip("barra", 20); 
this.barra.lineStyle(10, 0xFF0000,100); 
this.barra.lineTo(this.barra._x+200, this.barra._y); 
this.barra._xscale=0; 

  
//codigo Test end

--------------------------------------------------------------------------------



------------ORIGINAL CODE by Marcos



/* Este preloader generico es un Prototipo para precargar desde cualquier clip */ 
MovieClip.prototype.cargaJPG = function(imagen, contenedor, posx, posy, prof) 
{ 
/* La funcion recibe los siguientes parametros: 
imagen: imagen a cargar 
contenedor: nombre del clip que se creara y donde se cargara la imagen 
posx: posicion en eje x de lo que se cargara 
posy: posicion en eje y de lo que se cargara 
prof: nivel de profundidad donde  se cargara 
*/ 

// Eliminamos el clip contenedor, por si ya existiera 
// si no existe simplemente esto no hace nada. 
   delete (this[contenedor]); 
    
// Creamos el clip donde se cargara el JPG 
   this.createEmptyMovieClip(contenedor, prof); 

// creamos el texto que indicara el porcentaje 
this.createTextField("cargador", prof+1000, posx, posy, 100, 20); 
cargadorFormateado = new TextFormat(); 
cargadorFormateado.font = "Verdana"; 
cargadorFormateado.size = 2; 
cargadorFormateado.bold = true; 
cargadorFormateado.align = "Center"; 

// Creamos la barra que indicarĂ¡ el progreso 
this.createEmptyMovieClip("barra",20); 
this.barra.lineStyle(10,0x777777,100); 
this.barra.lineTo(this.barra._x+200, this.barra._y); 
this.barra._xscale=0; 

// Mandamos cargar la imagen que se le pasa a la funcion en el contendor 
   this[contenedor].loadMovie(imagen); 
// le damos al MovieClip la capadidad de controlar lo que va cargado mediante 
// su evento onEnterFrame. Esto implica que solo es valido para Flash MX 
   this.onEnterFrame = function() 
   { 
   // Clasica formula de precargador 
   this.porcentaje = (this[contenedor].getBytesLoaded()/this[contenedor].getBytesTotal())*100; 
   if (this.porcentaje<100) 
   { 
      this.cargador.text=Math.round(this.porcentaje)+"% cargado"; 
     this.barra._xscale=this.porcentaje; 
     this.cargador.setTextFormat(formatoTexto); 
   } 
   else 
   { 
      // Si ya esta cargado, lo colocamos donde le indicamos a la funcion 
      // y eliminamos el resto de clips innecesarios y eventos para no 
      // consumir mas recursos 
      if (this[contenedor]._width>0) 
      { 
         this[contenedor]._x=posx; 
         this[contenedor]._y=posy; 
         this.cargador.removeTextField(); 
       this.barra.removeMovieClip(); 
         delete(this.onEnterFrame); 
      } 
   } 
   } 
} 

//mi funcion controladora de tiempo creada con setInterval 
function espera() 
{                
// La action que yo quiero ejecutar en un tiempo 
//determinado es esta: 
// _root.arriba.cargaJPG("image1.jpg","punto",100,10,1); 
listaimagenes = ["imagen_1.jpg","imagen_2.jpg","imagen_3.jpg"]; 
pos = random(listaimagenes.length+1); 
_root.cargaJPG(listaimagenes[pos],"contenedor",100,10,1); 
} 

miReloj = setInterval(espera, 10000);