Les dejo la descarga de todo para que lo prueben rapido:
http://www.megaupload.com/?d=AITQO9YV
Y un ejemplo asi nomás:

Main.as
Código ActionScript :
package
{
import flash.display.MovieClip;
import com.lucasmoyano.preload.Preload;
public class Main extends MovieClip
{
private var PreCarga:Preload;
public function Main():void
{
PreCarga = new Preload(2, "Cargando ", "kb de ", "kb");
addChild(PreCarga);
}
}
}
Preload.as
Código ActionScript :
package com.lucasmoyano.preload
{
// Librerías Utilizadas
import com.lucasmoyano.preload.components.TxtLoading;
import com.lucasmoyano.preload.components.MCLoading;
import flash.display.MovieClip;
import flash.events.ProgressEvent;
import flash.events.Event;
import flash.text.TextField;
import flash.text.TextFormat;
public class Preload extends MovieClip
{
// Variables
private var txtLoading:TxtLoading;
private var mcLoading:MCLoading;
private var loadBytes:Number;
private var totalBytes:Number;
// Método Constructor
public function Preload(_type:uint = 1, _string1:String = "Loading ", _string2:String = "/", _string3:String = " bytes", _font:TextFormat = null):void
{
loadBytes = totalBytes = 0;
txtLoading = new TxtLoading(_type,_string1,_string2,_string3,_font);
mcLoading = new MCLoading();
addEventListener(Event.ADDED_TO_STAGE, Init);
}
// Inicialización
private function Init(e:Event):void
{
Main(root).stop();
addChild(mcLoading);
txtLoading.p_preloadStage = stage;
removeEventListener(Event.ADDED_TO_STAGE, Init);
loaderInfo.addEventListener(ProgressEvent.PROGRESS, onLoadProgress);
loaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
}
// Progreso de la Precarga
private function onLoadProgress(event:ProgressEvent):void
{
loadBytes = event.bytesLoaded;
totalBytes = event.bytesTotal;
txtLoading.onLoadProgress(loadBytes, totalBytes);
mcLoading.onLoadProgress(loadBytes, totalBytes);
}
// Fin de la Precarga
private function onLoadComplete(event:Event):void
{
removeEventListener(ProgressEvent.PROGRESS, onLoadProgress);
removeEventListener(Event.COMPLETE, onLoadComplete);
removeChild(mcLoading);
txtLoading.RemoveText();
Main(root).play();
}
}
}
MCLoading.as
Código ActionScript :
package com.lucasmoyano.preload.components
{
import flash.display.MovieClip;
import flash.events.ProgressEvent;
import flash.events.Event;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.display.Stage;
public class MCLoading extends MovieClip
{
public function MCLoading():void
{
gotoAndStop(1);
}
// Progreso de la Precarga
public function onLoadProgress(_loadBytes:Number, _totalBytes:Number):void
{
gotoAndStop(Math.round(totalFrames*_loadBytes/_totalBytes));
x = stage.stageWidth / 2 - width / 2;
y = stage.stageHeight / 2 - height / 2;
}
}
}
[/code]
TxtLoading.as:
[code]
package com.lucasmoyano.preload.components
{
import flash.text.TextField;
import flash.text.TextFormat;
import flash.display.Stage;
public class TxtLoading
{
// Variables
private var type:uint;
private var loadBytes:Number;
private var totalBytes:Number;
private var string1:String;
private var string2:String;
private var string3:String;
private var txtLoading:TextField;
private var flagInit:Boolean;
private var preloadStage:Stage;
// Método Constructor
public function TxtLoading(_type:uint, _string1:String, _string2:String, _string3:String, _font:TextFormat):void
{
type = _type;
string1 = _string1;
string2 = _string2;
string3 = _string3;
txtLoading = new TextField();
flagInit = false;
if (_font != null)
{
txtLoading.setTextFormat(_font);
}
}
// Progreso de la Precarga
public function onLoadProgress(_loadBytes:Number, _totalBytes:Number):void
{
loadBytes = _loadBytes;
totalBytes = _totalBytes;
if (! flagInit)
{
txtLoading.y = preloadStage.stageHeight / 2;
preloadStage.addChild(txtLoading);
flagInit = true;
}
switch (type)
{
case 1 :// Texto en Bytes
txtLoading.text = string1 + loadBytes + string2 + totalBytes + string3;
break;
case 2 :// Texto en Kilobytes
txtLoading.text = string1 + Math.round(loadBytes / 1024) + string2 + Math.round(totalBytes / 1024) + string3;
break;
case 3 :// Texto en Megabytes
txtLoading.text = string1 + Math.round(loadBytes / 1024 / 1024*100)/100 + string2 + Math.round(totalBytes / 1024 / 1024*100)/100 + string3;
break;
case 4 :// Texto en Porcentaje
txtLoading.text = string1 + Math.round(100 * loadBytes / totalBytes) + string3;
break;
default :// Sin texto
break;
}
txtLoading.width = txtLoading.textWidth + 10;
txtLoading.x = preloadStage.stageWidth / 2 - txtLoading.width / 2;
}
// Elimina el texto del escenario
public function RemoveText():void
{
preloadStage.removeChild(txtLoading);
}
// Propiedades de preloadStage
public function get p_preloadStage():Stage
{
return preloadStage;
}
public function set p_preloadStage(value:Stage):void
{
preloadStage = value;
}
}
}
En el archivo flash utilizen la clase Main.as, y tambien pueden colocar un MC con animacion, cuya vinculación sea:
com.lucasmoyano.preload.components.MCLoading
Cuando prueben la pelicula, acuerdense de poner Ver->Simular Descarga
Chaus!
