He dado con la solución a un problema que me llevaba de cabeza desde hace tiempo, los fallos de carga del componente Loader y del Scrollpane una vez subidos a la web
He leído que mucha gente, al igual que yo, les dan problemas una vez colgada la web, problemas como no hacer el scroll, o el escalado, o salirse del espacio del componente...
He investigado, probado, y reprobado, y he encontrado esta explicación y solución al problema:
Los amigos de bgxcomponents.com publican en su web, que el problema del Loader viene dado porque el indicador de progreso de carga, se queda en _totalBytes -1 hasta completar el último frame, cuando el componente chequea el progreso de carga y aparece en total-1 por 3 veces, lo da por terminado y empieza la reproducción. Por tanto, como no está completo y no tiene las medidas totales, no hace bien el escalado.
Y esto ocurre, cuando tenemos una conexión lenta a internet, por ejemplo con un módem USB de GSM o 3G.
También aportan la solución, la única que funciona de todas las que he probado.
La solución, es hacer una pequeña modificación al código del componente, para que haga la comprobación más de 3 veces, yo he probado varias opciones, y con 5000 veces, carga bien hasta con un modem de 14.400 ![]()
El código a añadir sería el siguiente: (a poner en el frame 1, antes de los load()
Código :
import mx.controls.Loader;
//define the maxTries here.
var maxTries:Number = 5000;
Loader.prototype.checkLoadProgress = function():Void
{
var i:String;
for (i in this.loadList)
{
var x:Object = this.loadList[i];
//trace("loading..." + loadList[i].url);
x.loaded = x.obj.getBytesLoaded();
x.total = x.obj.getBytesTotal();
//trace( x.loaded +"/"+ x.total );
if (x.total > 0)
{
x.obj._visible = false;
this.dispatchEvent({type:"progress", target:x.obj, current:x.loaded, total:x.total});
if (x.loaded == x.total)
{
if (this.loadedList == undefined)
{
this.loadedList = new Object();
}
this.loadedList[i] = x;
delete this.loadList[i];
this.doLater(this,"contentLoaded");
}
else
{
//NOTE BGX: also this is different than in the original code where
//the call to doLater is outside the check "if (x.total > 0)"
this.doLater(this,"checkLoadProgress");
}
}
else
{
if (x.total == -1)
{
// sometimes you get a -1 before it starts loading
if (x.failedOnce != undefined)
{
x.failedOnce++;
//NOTE BGX: the following is the line changed [orig: if (x.failedOnce > 3)]
if (x.failedOnce > maxTries)
{
this.dispatchEvent({type:"complete", target:x.obj, current:x.loaded, total:x.total});
//trace("total == -1 loaded = " + x.loaded);
delete this.loadList[i];
delete x;
}
}
else
{
x.failedOnce = 0;
}
}
//NOTE BGX: also this is different than in the original code where
//the call to doLater is outside the check "if (x.total > 0)"
this.doLater(this,"checkLoadProgress");
}
}
};Código :
import mx.containers.ScrollPane;