Yo no lo haría con un setinterval... Cuándo flash tiene una
precioooooooooosa timeline que utilizar... :)

        Te voy a poner cómo lo hago yo; bueno, concretamente una clase
guarra que hice para AS 1; es una clase cutre, que hice deprisa y corriendo,
lo bueno que tiene es que funciona.. Lo malo es que es algo "tocha", pero
supongo que te dará ideas -aparte de que es AS 1.0 claro-

[code_class]

/*
****************************************************************************
*********
*

*  Proyecto:    Creación de Clase cargadora de un JPG en un movieclip

*  Autor:        JRPrieto aka HariSeldon

*  Última Modificación:      29/01/2004

*  Descripción:  Clase para controlar la carga de una imagen JPG en un
movieclip, con su preload
*  @(#)classMCLoaderJPG.as 0.1 04/01/29
*  @version 0.1 04/01/29
*  @author Jose R. Prieto aka HariSeldon
*                                                                
****************************************************************************
***********/
/*
* CLASS.FILE                 classMCLoaderJPG.as
* CLASS.NAME               MCLoaderJPG
* CLASS.VERSION           0.1 (AS v.1 , compatible con Flash MX)
* CLASS.LAST.MODIFIED  29 Enero 2004
* CLASS.SUMMARY          Clase para controlar la carga de una imagen JPG en
un movieclip, con su preload
*
* @version 0.1 04/01/29
* @author Jose R. Prieto
*/

// Constructor de la Clase:
_global.MCLoaderJPG = function (mcToLoadJPG_pointer, jpgToLoad_str,
pointersmcLoaders_array, pointersmcPhoto_array, titlesImg_array)        {
        this.$className = "MCLoaderJPG";
        this.$classVersion = "0.1";     
        this.$classAutor = "J.R.Prieto aka Hari Seldon";
        this.$library = "HariSeldonsASLibrary";
        this.$libraryVersion = "0.1";   
        this.$package = "UtilsMathsAndMotions"; 
        // se inicializa la clase aquí:
        this.init(mcToLoadJPG_pointer, jpgToLoad_str,
pointersmcLoaders_array, pointersmcPhoto_array, titlesImg_array);
};

// inicialización de la clase (init): 
MCLoaderJPG.prototype.init = function(mcToLoadJPG_pointer, jpgToLoad_str,
pointersmcLoaders_array, pointersmcPhoto_array, titlesImg_array)        {
        // Debug:
//      trace("inicializando la clase...");
//      trace(arguments);
        // Puntero al MC que hay que controlar:
        this.$mcToLoadJPG_pointer = mcToLoadJPG_pointer;
        this.$jpgToLoad_str = jpgToLoad_str;
        // puntero del MC a controlar a la instancia de esta clase:
        this.$mcToLoadJPG_pointer.classControllerLoad_pointer = this;
        // vars of the preload in the MC:
        this.$mcToLoadJPG_pointer.bytesLoaded_int = 0;
        this.$mcToLoadJPG_pointer.bytesTotal_int = 0;
        this.$mcToLoadJPG_pointer.imgLoaded_bol = false;
        // vars for the preload:
        this.$mcToLoadJPG_pointer.mcTextLoading_pointer =
pointersmcLoaders_array[0]?pointersmcLoaders_array[0]:null;
        this.$mcToLoadJPG_pointer.mcMaskPreload_pointer =
pointersmcLoaders_array[1]?pointersmcLoaders_array[1]:null;
        this.$mcToLoadJPG_pointer.mcImgLoader_pointer =
pointersmcLoaders_array[2]?pointersmcLoaders_array[2]:null;
        this.$mcToLoadJPG_pointer.mcBgLoader_pointer =
pointersmcLoaders_array[3]?pointersmcLoaders_array[3]:null;
        
//      trace(this.$mcToLoadJPG_pointer.mcTextLoading_pointer);
//      trace(this.$mcToLoadJPG_pointer.mcMaskPreload_pointer); 
//      trace(this.$mcToLoadJPG_pointer.mcImgLoader_pointer);
//      trace(this.$mcToLoadJPG_pointer.mcBgLoader_pointer);
        // vars for the container of the image:
//      trace(pointersmcPhoto_array);
        this.$mcToLoadJPG_pointer.mcMaskImg_pointer =
pointersmcPhoto_array[0]?pointersmcPhoto_array[0]:null;
        this.$mcToLoadJPG_pointer.mcImgContainer_pointer =
pointersmcPhoto_array[1]?pointersmcPhoto_array[1]:null;
        this.$mcToLoadJPG_pointer.mcBgImg_pointer =
pointersmcPhoto_array[2]?pointersmcPhoto_array[2]:null;
//      trace(this.$mcToLoadJPG_pointer.mcMaskImg_pointer);     
//      trace(this.$mcToLoadJPG_pointer.mcImgContainer_pointer);        
//      trace(this.$mcToLoadJPG_pointer.mcBgImg_pointer);       
        // vars for title and desc of the image:
        this.$mcToLoadJPG_pointer.titleImg_str =
titlesImg_array[0]?titlesImg_array[0]:null;
        this.$mcToLoadJPG_pointer.descImg_str =
titlesImg_array[1]?titlesImg_array[1]:null;
        // vars of dimensions of mask and image:
        this.$mcToLoadJPG_pointer.wPhoto_int = 0;
        this.$mcToLoadJPG_pointer.hPhoto_int = 0;
        this.$mcToLoadJPG_pointer.wMask_int =
pointersmcPhoto_array[0]?(pointersmcPhoto_array[0]._width):null;
        this.$mcToLoadJPG_pointer.hMask_int =
pointersmcPhoto_array[0]?(pointersmcPhoto_array[0]._height):null;
        
        // put on the true values of the visibility:
        this.$mcToLoadJPG_pointer.mcTextLoading_pointer._visible = true;
        this.$mcToLoadJPG_pointer.mcMaskPreload_pointer._visible = true;
        this.$mcToLoadJPG_pointer.mcImgLoader_pointer._visible = true;
        this.$mcToLoadJPG_pointer.mcBgLoader_pointer._visible = true;
        this.$mcToLoadJPG_pointer.mcMaskImg_pointer._visible = false;
        this.$mcToLoadJPG_pointer.mcImgContainer_pointer._visible = false;
        this.$mcToLoadJPG_pointer.mcBgImg_pointer._visible = false;
};
MCLoaderJPG.prototype.startLoad = function() {
        // now we must load the image:
        // first, we must call the loadMovie in the container of the Image:
        
this.$mcToLoadJPG_pointer.mcImgContainer_pointer.loadMovie(this.$jpgToLoad_s
tr);
        // second, we must put visible or invisible the MCs:
        this.$mcToLoadJPG_pointer.mcTextLoading_pointer._visible = true;
        this.$mcToLoadJPG_pointer.mcMaskPreload_pointer._visible = true;
        this.$mcToLoadJPG_pointer.mcImgLoader_pointer._visible = true;
        this.$mcToLoadJPG_pointer.mcBgLoader_pointer._visible = true;
        this.$mcToLoadJPG_pointer.mcMaskImg_pointer._visible = false;
        this.$mcToLoadJPG_pointer.mcImgContainer_pointer._visible = false;
        this.$mcToLoadJPG_pointer.mcBgImg_pointer._visible = false;
        // third, we must do the preload with the arguments (pointers to MC
in the MC to control)
        this.$mcToLoadJPG_pointer.onEnterFrame = function() {
//              var bytesLoaded_int, bytesTotal_int, imgLoaded_bol;
//              var mcTextLoading_pointer, mcMaskPreload_pointer,
mcImgLoader_pointer, mcBgLoader_pointer;
//              var mcMaskImg_pointer, mcImgContainer_pointer,
mcBgImg_pointer;
//              var titleImg_str, descImg_str;
//              var wPhoto_int, hPhoto_int, wMask_int, hMask_int;
//              trace(this.mcImgContainer_pointer);
                this.bytesTotal_int =
this.mcImgContainer_pointer.getBytesTotal();
                if (bytesTotal_int != -1) {
                        
                        this.bytesLoaded_int =
this.mcImgContainer_pointer.getBytesLoaded();
//                      trace(this.bytesLoaded_int);
//                      trace(this.bytesTotal_int);
                        // event that the image is loading, and now are
"bytesLoaded_int" bytes loaded of "bytesTotal_int" bytes total:
        
this.classControllerLoad_pointer.onLoadingJPG(this.bytesLoaded_int,
this.bytesTotal_int);
//                      trace((this.bytesLoaded_int ==
this.bytesTotal_int));
                        if (this.bytesLoaded_int == this.bytesTotal_int) {
                                // event that the image is now loaded:
                                // the image is now loaded
        
this.classControllerLoad_pointer.onLoadedJPG();
                                this.onEnterFrame = undefined;
        
this.classControllerLoad_pointer.resizeImage();
                                this.mcTextLoading_pointer._visible = false;
                                this.mcMaskPreload_pointer._visible = false;
                                this.mcImgLoader_pointer._visible = false;
                                this.mcBgLoader_pointer._visible = false;
                                this.mcMaskImg_pointer._visible = true;
                                this.mcImgContainer_pointer._visible = true;
                                this.mcBgImg_pointer._visible = true;
                                this.wPhoto_int =
this.mcImgContainer_pointer._width;
                                this.hPhoto_int =
this.mcImgContainer_pointer._height;
                        } else {
                                this.mcMaskPreload_pointer._xscale =
(this.bytesLoaded_int / this.bytesTotal_int) * 100;
                        }
                }
        };
};
MCLoaderJPG.prototype.resizeImage = function() {
        var wImg_int, hImg_int, wMask_int, hMask_int, xInitImage_int,
yInitImage_int; 
        wImg_int = this.$mcToLoadJPG_pointer.mcImgContainer_pointer._width;
        hImg_int= this.$mcToLoadJPG_pointer.mcImgContainer_pointer._height;
        xInitImage_int =
this.$mcToLoadJPG_pointer.mcImgContainer_pointer._x;
        yInitImage_int =
this.$mcToLoadJPG_pointer.mcImgContainer_pointer._y;
        wMask_int = this.$mcToLoadJPG_pointer.mcMaskImg_pointer._width;
        hMask_int = this.$mcToLoadJPG_pointer.mcMaskImg_pointer._height;
//      trace(wImg_int + " || " + hImg_int);
        //trace(wPhoto_int + "x" + hPhoto_int);
        if (wImg_int >= hImg_int)       {
                this.$mcToLoadJPG_pointer.mcImgContainer_pointer._width =
wMask_int;
                this.$mcToLoadJPG_pointer.mcImgContainer_pointer._height =
(hImg_int /wImg_int ) * wMask_int;
        } else {
                this.$mcToLoadJPG_pointer.mcImgContainer_pointer._height =
hMask_int;
                this.$mcToLoadJPG_pointer.mcImgContainer_pointer._width =
(wImg_int / hImg_int) * hMask_int;                                      
        }
//      trace(this.$mcToLoadJPG_pointer.mcImgContainer_pointer._height + "
|| " + this.$mcToLoadJPG_pointer.mcImgContainer_pointer._width);
        this.$mcToLoadJPG_pointer.mcImgContainer_pointer._x =
this.$mcToLoadJPG_pointer.mcMaskImg_pointer._x + ((wMask_int - 
                this.$mcToLoadJPG_pointer.mcImgContainer_pointer._width) /
2);
        this.$mcToLoadJPG_pointer.mcImgContainer_pointer._y =
this.$mcToLoadJPG_pointer.mcMaskImg_pointer._y + ((hMask_int - 
                this.$mcToLoadJPG_pointer.mcImgContainer_pointer._height) /
2);
};

MCLoaderJPG.prototype.setMCtoLoadJPG = function(mcToLoadJPG_pointer,
jpgToLoad_str, pointersmcLoaders_array, pointersmcPhoto_array,
titlesImg_array){
        this.init(mcToLoadJPG_pointer, jpgToLoad_str,
pointersmcLoaders_array, pointersmcPhoto_array, titlesImg_array);
};

[/code_class]

 

Y para llamarla, lo hago así:

[code]

var myLoaderHomeJPG = new
MCLoaderJPG(_root.insContent.insHome.insPhotoHome.insPhoto00,
"./img/recepcion_carmen_bianca_1.jpg", 
[_root.insContent.insHome.insPhotoHome.insPhoto00.insTextLoading,
_root.insContent.insHome.insPhotoHome.insPhoto00.insMaskPreload, 
_root.insContent.insHome.insPhotoHome.insPhoto00.insImgLoaderPhoto,
_root.insContent.insHome.insPhotoHome.insPhoto00.insBgLoader], 
[_root.insContent.insHome.insPhotoHome.insPhoto00.insMaskPhoto,
_root.insContent.insHome.insPhotoHome.insPhoto00.insPhotoContainer, 
_root.insContent.insHome.insPhotoHome.insPhoto00.insBgPhoto], ["prueba",
"descripción de prueba"]);
myLoaderHomeJPG.startLoad();

[/code]

Parámetros:
_global.MCLoaderJPG = function (mcToLoadJPG_pointer, jpgToLoad_str,
pointersmcLoaders_array, pointersmcPhoto_array, titlesImg_array)

mcToLoadJPG_pointer: puntero o referencia al MC dónde se quiere cargar el
JPG.
jpgToLoad_str: string con la ruta del jpg que queremos cargar.
pointersmcLoaders_array: array con referencias a MC que harán las funciones
del preload; son, por orden:
        - referencia a MC con texto "cargando"
        - referencia a MC con máscara de la imagen del preload (para
enseñar/ocultar/irla escalando para que haga el efecto de "subir")
        - referencia a MC con imagen de la precarga
        - referencia a MC con imagen de fondo de la precarga
pointersmcPhoto_array; array con referencias a MC que harán ciertas
funciones en la foto una vez cargada; de nuevo, por orden:
        - referencia a máscara de la imagen que se carga (enseñar/ocultar)
        - referencia al MC contenedor de la imagen
        - referencia a la imagen o MC de fondo de la imagen
titlesImg_array: array con textos referentes a la imagen:
        - título
        - descripción


Saludos.

> -----Mensaje original-----
> De: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] En nombre de David Pariente
> Enviado el: miércoles, 06 de octubre de 2004 21:51
> Para: ACTION SCRIPT
> Asunto: [ASNativos] problema porcentage precarga JPG <-- el codigo
> 
> show_big_photo=function(photo) {
>       
>       this.createEmptyMovieClip("bigfoto", 13500);
>       
>       bigfoto._alpha=0;
>       loadMovie("fotos/"+photo[0]+"_b.jpg","bigfoto");
>       
>       data=new Array();
>       
>       data[line,col,2]=photo[2];
>       
> 
>       var bf = setInterval(function (mc,data) {
>               estabigfoto=mc["bigfoto"];
>       
>                       
>               if ((mc["bigfoto"].getBytesLoaded() <= 1) || 
>                         (mc["bigfoto"].getBytesLoaded() <
> (mc["bigfoto"].getBytesTotal()-10)) ) 
>           { 
>               
>               //if (estabigfoto.getBytesLoaded() > 1) {
>               
> attachMovie("mc_loading_percent","mc_loading2",100000);
>       mc_loading2._x=bfcenterx-(mc_loading2._width/2);
>       mc_loading2._y=bfcentery-(mc_loading2._height/2);
>               
> percent=(estabigfoto.getBytesLoaded())/estabigfoto.getBytesTotal();
>                       percentatge=Math.floor((16*percent));
>                       pagefoot.text=steps+" "+percent+"%,
> "+estabigfoto.getBytesLoaded()+" of
> "+estabigfoto.getBytesTotal();
>                       steps++;
>                       mc_loading2.removeMovieClip();
>                       mc_loading2.gotoandplay(percentatge+1);
>                       
>               //}
>           } else {
>  
>                       
> //pagefoot.text="popo"+estabigfoto.getBytesLoaded()+"
> of "+estabigfoto.getBytesTotal();
>  
>                estabigfoto._alpha = 99;
>               clearInterval(bf);
>                        mc_loading2.removeMovieClip();
>                        if (estabigfoto._width>estabigfoto._height)
>                        {              
>                               orient="h";
>                        } else         {       
>                               orient="v";
>                        }
>                       
>                   //etc...etc....esto funciona bien
> 
>                               }
>    }, 80, this,data);
> }
> 
> 
>               
> ______________________________________________
> Renovamos el Correo Yahoo!: ¡100 MB GRATIS!
> Nuevos servicios, más seguridad
> http://correo.yahoo.es
> ----------------------------------
> Lista ASNativos:[EMAIL PROTECTED]
> http://www.5dms.com/listas
> ----------------------------------
> 


----------------------------------
Lista ASNativos:[EMAIL PROTECTED]
http://www.5dms.com/listas
----------------------------------

Responder a