class fotos.Preloader { private var acargar; private var callback; //Ruta a cargar private var ruta:String; private var blackBoard:MovieClip; private var ruta_mc:MovieClip; private var hilo:Number; private var ambito; function Preloader(obj, ruta:String, blackboard:MovieClip, container:MovieClip, ambito, callback) { this.ambito = ambito; this.callback = callback; this.ruta = ruta; this.blackBoard = blackboard; acargar = obj; ruta_mc = container; cargador(acargar, this); } private function cargador(load_mc, clase):Void { var loader_mcl:MovieClipLoader = new MovieClipLoader(); var lListener:Object = new Object(); clase.dibujar(1, 100); lListener.onLoadStart = function() { clase.dibujar(1, 100); }; lListener.onLoadProgress = function(loading, loaded, total) { clase.dibujar(loaded, total); }; lListener.onLoadComplete = function(loaded) { clase.blackBoard.clear(); clase.callback(); }; loader_mcl.addListener(lListener); loader_mcl.loadClip(clase.ruta, load_mc); } private function dibujar(cargados:Number, total:Number):Void { var llena:Number; var laX:Number; var laY:Number; var anX:Number; var anY:Number; var porcentaje:Number; llena = blackBoard._width*.78; porcentaje = parseInt(String((cargados*100)/total)); blackBoard.lineStyle(0, 0x666666, 100); // Dibujamos el cuadro contenedor laX = ((blackBoard._width/2)*.2); laY = (blackBoard._height/2)-7; anX = laX; anY = laY; blackBoard.beginFill(0xFFFFFF, 50); blackBoard.moveTo(laX, laY); laX += (llena+2); blackBoard.lineTo(laX, laY); laY += 14; blackBoard.lineTo(laX, laY); laX -= (llena+2); blackBoard.lineTo(laX, laY); blackBoard.endFill(); // Creamos la barra de laX = ((blackBoard._width/2)*.2)+2; laY = (blackBoard._height/2)-5; blackBoard.beginFill(0x666666, 50); blackBoard.moveTo(laX, laY); laX += (llena*(porcentaje/100)); blackBoard.lineTo(laX, laY); laY += 10; blackBoard.lineTo(laX, laY); laX -= (llena*(porcentaje/100)); blackBoard.lineTo(laX, laY); blackBoard.lineTo(anX, anY); blackBoard.endFill(); } }