1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| function preloadimage(cible:MovieClip, xc:Number, yc:Number, id:Number)
{
cible.attachMovie("zonepctxt","zonepctxt",cible.getNextHighestDepth()); //Clip contenant un texte dynamique (pct) pour afficher le chargement
zonepctxt._x = xc;
zonepctxt._y = yc;
cible.createEmptyMovieClip("image",cible.getNextHighestDepth());
image._x = xc;
image._y = yc;
image._alpha = 0;
image.loadMovie("ref/" + id + ".jpg");
cible.onEnterFrame = function()
{
var bt:Number = image.getBytesTotal();
var bl:Number = image.getBytesLoaded();
var per:Number = ! bt ? 0 : Math.floor(bl/bt*100);
zonepctxt.pct.text = "Chargement image : " + per + "%";
if (per == 100)
{
zonepctxt.pct.text = "";
if (image._alpha < 100)
image._alpha += 10;
else
delete cible.onEnterFrame;
}
}
};
preloadimage(this, 0, 200, 15); //fonctionne correctement dans la 1re image
_root.preloadimage(this, 0, 200, 15);//ne fonctionne pas dans un clip |
Partager