1) Estoy implementando una precarga, en el Document Class el problema radica en que la function showProgress(event:ProgressEvent), solo se ejecuta una sola vez y no puedo ver el avance de la carga.
2) El archivo swf de 525KB, aproximadamente se tarda unos 5 segundos en cargarse.
3) La linea de tiempo principal no tiene código y no tiene información.
4) Todas la información esta en la bibiloteca y se accesa a través del Document Class.
5) El Dclass_main.as tiene lo siguiente:
Código :
package {
import flash.display.*;
import flash.events.*;
import flash.text.TextField;
import flash.text.TextFormat;
public class Dclass_main extends MovieClip {
public var loadBar:Sprite;
public var fig:Shape = new Shape;
public var _tf:TextField;
public var _fmt:TextFormat;
public function Dclass_main() {
prepara_info();
//Events
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, showProgress);
this.loaderInfo.addEventListener(Event.COMPLETE, initApplication);
trace ("this: " + this); // SALIDA -> this: [object Dclass_main].
}
public function showProgress(event:ProgressEvent):void {
var cargado:int = event.bytesLoaded;
var total:int = event.bytesTotal;
var porcentaje:int = cargado/total*100;
trace("Bytes Cargados: " + cargado); // Salida -> Bytes Cargados: 537377
trace("Bytes Total: " + total); // Salida -> Bytes Total: 537377
trace(porcentaje); // Salida: 100%
//LoadBar
with (loadBar.graphics) {
clear();
beginFill(0xff0000);
drawRect(11,stage.stageHeight-19,3*porcentaje-2,8);
endFill();
}
//Text
_tf.text = "Cargando: "+ porcentaje + " %";
}
function prepara_info():void {
loadBar = new Sprite();
addChild(loadBar);
//Draw Bound
with (this.graphics) {
beginFill(0x0000ff);
drawRect(10,stage.stageHeight-20,300,10);
endFill();
}
//Text
_fmt = new TextFormat("_sans", 11, 0x0000ff);
_tf = createText();
addChild(_tf);
_tf.x = 9;
_tf.y = stage.stageHeight - 40;
_tf.text = "Cargando: 0 %";
}
public function createText():TextField {
var t:TextField = new TextField();
t.width = 0;
t.height = 0;
t.autoSize = TextFieldAutoSize.LEFT;
t.selectable = false;
t.defaultTextFormat = _fmt;
return t;
}
public function initApplication(event:Event):void {
//Clean
this.graphics.clear();
loadBar.graphics.clear();
_tf = null;
// Continua con el programa
....
....
....
}El programa no marca error
El problema es que no veo el avance de la carga (porcentaje 10%, 20%, 30%, 40%, etc) la función de showProgress, solo se ejecuta una sola vez y se observa por que al desplejar la información el porcentaje es del 100%:
trace("Bytes Cargados: " + cargado); // Salida -> Bytes Cargados: 537377
trace("Bytes Total: " + total); // Salida -> Bytes Total: 537377
trace(porcentaje); // Salida: 100%
De antemano muchas gracias por su atención, culaquier sugerencia es bien recibida.
Saludos
