El tamaño de imagen en movimiento no funciona cuando se carga la imagen

  • clem_c_rock
  • Novice
  • Novice
  • No Avatar
  • Registrado: Ago 22, 2006
  • Mensajes: 20
  • Status: Offline

Nota Octubre 26th, 2007, 6:35 am

Hola,
Im tener un poco de suerte extraña en la construcción de una presentación de diapositivas de imágenes. Me carga las rutas de la imagen en una matriz de un XML
la página y, a continuación paso a través de los elementos de la matriz w / botones adelante y atrás.

Tengo un clip de imagen vacía en la etapa en la que puedo crear un clip de película vacío en su interior cada vez que una nueva imagen es cargada. Me carga la
de imagen en el segundo clip de película como esta:

Código: [ Select ]
_root.picsPage_mc.mc_pic_loader.mc_individual_pic_loader.unloadMovie();
_root.picsPage_mc.mc_pic_loader.createEmptyMovieClip( 'mc_individual_pic_loader', 1 );
_root.load_movie_and_stop( _root.picsPage_mc.mc_pic_loader.mc_individual_pic_loader, _root.photo_array[_root.photo_index].image, _root.picsPage_mc.mc_pbar, 'regular_load');
  1. _root.picsPage_mc.mc_pic_loader.mc_individual_pic_loader.unloadMovie();
  2. _root.picsPage_mc.mc_pic_loader.createEmptyMovieClip( 'mc_individual_pic_loader', 1 );
  3. _root.load_movie_and_stop( _root.picsPage_mc.mc_pic_loader.mc_individual_pic_loader, _root.photo_array[_root.photo_index].image, _root.picsPage_mc.mc_pbar, 'regular_load');



La función load_movie_and_stop es el siguiente:
Código: [ Select ]
function load_movie_and_stop( target_mc:MovieClip, movie_clip_to_load:String, p_bar:MovieClip, action:String )
{
     mc_loader._width = 0;
     mc_slider_bar.mc_drag_pan._x = 0;
              
     if( action != 'simple_load' )
     {
       p_bar._visible = true;
         p_bar.bar._width = 0;
    }    
                
     var mclListener:Object = new Object();
     mclListener.onLoadStart = function( target_mc )  
     {
         if( action != 'simple_load' && action != 'regular_load' ){ target_mc.stop(); } 
         if( action == 'load_and_play' ){ target_mc.play(); }
     }
    
     mclListener.onLoadInit = function( target_mc )
     {        
         _root.resize_movie_clip(target_mc, 160, 120, 250, 190);
         if( action == 'load_and_stop' ){ target_mc.stop(); }
     }
     
     mclListener.onLoadProgress = function( target_mc )
   {
         
     if( action != 'simple_load' )
         {
        percentLoaded = Math.floor( ( target_mc.getBytesLoaded()/target_mc.getBytesTotal() )*100);
        p_bar.bar._xscale = percentLoaded;
        p_bar.txt_percent = percentLoaded + "% loaded.";
         }
   }
     
     mclListener.onLoadComplete = function( target_mc ){ p_bar._visible = false; }

   var my_mcl:MovieClipLoader = new MovieClipLoader();
   my_mcl.addListener(mclListener);
   my_mcl.loadClip( movie_clip_to_load, target_mc );

}//___endFunc___                
  1. function load_movie_and_stop( target_mc:MovieClip, movie_clip_to_load:String, p_bar:MovieClip, action:String )
  2. {
  3.      mc_loader._width = 0;
  4.      mc_slider_bar.mc_drag_pan._x = 0;
  5.               
  6.      if( action != 'simple_load' )
  7.      {
  8.        p_bar._visible = true;
  9.          p_bar.bar._width = 0;
  10.     }    
  11.                 
  12.      var mclListener:Object = new Object();
  13.      mclListener.onLoadStart = function( target_mc )  
  14.      {
  15.          if( action != 'simple_load' && action != 'regular_load' ){ target_mc.stop(); } 
  16.          if( action == 'load_and_play' ){ target_mc.play(); }
  17.      }
  18.     
  19.      mclListener.onLoadInit = function( target_mc )
  20.      {        
  21.          _root.resize_movie_clip(target_mc, 160, 120, 250, 190);
  22.          if( action == 'load_and_stop' ){ target_mc.stop(); }
  23.      }
  24.      
  25.      mclListener.onLoadProgress = function( target_mc )
  26.    {
  27.          
  28.      if( action != 'simple_load' )
  29.          {
  30.         percentLoaded = Math.floor( ( target_mc.getBytesLoaded()/target_mc.getBytesTotal() )*100);
  31.         p_bar.bar._xscale = percentLoaded;
  32.         p_bar.txt_percent = percentLoaded + "% loaded.";
  33.          }
  34.    }
  35.      
  36.      mclListener.onLoadComplete = function( target_mc ){ p_bar._visible = false; }
  37.    var my_mcl:MovieClipLoader = new MovieClipLoader();
  38.    my_mcl.addListener(mclListener);
  39.    my_mcl.loadClip( movie_clip_to_load, target_mc );
  40. }//___endFunc___                


Después de la imagen se carga en el clip de película, a continuación, cambiar el tamaño de la imagen a un ancho específico.

El cambio de tamaño de imagen se hace w / esta función:
Código: [ Select ]
function resize_movie_clip(clip_loader_name:MovieClip, max_width:Number, max_height:Number )
{
   orig_width = clip_loader_name._width;
    orig_height = clip_loader_name._height;
    
    aspect_ratio = orig_width / orig_height;     
     
     if( (orig_width > max_width) || ( orig_height > max_height ) ) // If either dimension is too big...
    {
       if( orig_width > orig_height ) // For wide images...
       {
          new_width = max_height;
          new_height = new_width / aspect_ratio;
       } 
       else if( orig_width < orig_height )
       {
          new_height = max_height;
          new_width = new_height * aspect_ratio;
       }
       else if( orig_width == test_height )
       {
         new_width = max_width;
         new_height = max_width;
       }
       else { trace( "Error reading image size."); return false; }
   }
   else { new_width = orig_width; new_height = orig_height; }
     
   clip_loader_name._width = Math.round(new_width);
   clip_loader_name._height = Math.round(new_height);

};
  1. function resize_movie_clip(clip_loader_name:MovieClip, max_width:Number, max_height:Number )
  2. {
  3.    orig_width = clip_loader_name._width;
  4.     orig_height = clip_loader_name._height;
  5.     
  6.     aspect_ratio = orig_width / orig_height;     
  7.      
  8.      if( (orig_width > max_width) || ( orig_height > max_height ) ) // If either dimension is too big...
  9.     {
  10.        if( orig_width > orig_height ) // For wide images...
  11.        {
  12.           new_width = max_height;
  13.           new_height = new_width / aspect_ratio;
  14.        } 
  15.        else if( orig_width < orig_height )
  16.        {
  17.           new_height = max_height;
  18.           new_width = new_height * aspect_ratio;
  19.        }
  20.        else if( orig_width == test_height )
  21.        {
  22.          new_width = max_width;
  23.          new_height = max_width;
  24.        }
  25.        else { trace( "Error reading image size."); return false; }
  26.    }
  27.    else { new_width = orig_width; new_height = orig_height; }
  28.      
  29.    clip_loader_name._width = Math.round(new_width);
  30.    clip_loader_name._height = Math.round(new_height);
  31. };


Ahora, el 98% de las veces esto funciona perfectamente, pero hay algunos momentos determinados en que el cambio de tamaño de la imagen es completamente ignorado y la imagen se carga como su tamaño normal.

¿Alguien puede ver por qué el tamaño de la imagen es ignorada en algún caso?

Gracias por cualquier ayuda,
Clem
  • Anonymous
  • Bot
  • No Avatar
  • Registrado: 25 Feb 2008
  • Mensajes: ?
  • Loc: Ozzuland
  • Status: Online

Nota Octubre 26th, 2007, 6:35 am

  • graphixboy
  • Control + Z
  • Mastermind
  • Avatar de Usuario
  • Registrado: Jul 11, 2005
  • Mensajes: 1828
  • Loc: In the Great White North
  • Status: Offline

Nota Octubre 26th, 2007, 9:28 pm

es necesario que usted llame a su tamaño dentro de la función onComplete oyente.

El problema es que el flash no sabe el tamaño real de la imagen hasta después de la imagen se ha descargado por completo (ni idea de por qué, este rompecabezas mí también). Trabaja el 98% de las veces porque las imágenes suelen ser de carga con la suficiente rapidez para conseguir que los datos antes de llamar a la función.

Como alternativa se puede poner las dimensiones de la imagen en el archivo XML y, a continuación, hacer el tamaño de la base en que en lugar de esperar a la carga completa.

Publicar Información

  • Total de mensajes en este tema: 2 mensajes
  • Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 63 invitados
  • No puede abrir nuevos temas en este Foro
  • No puede responder a temas en este Foro
  • No puede editar sus mensajes en este Foro
  • No puede borrar sus mensajes en este Foro
  • No puede enviar adjuntos en este Foro
 
 

© 2011 Unmelted, LLC. Ozzu® es una marca registrada de Unmelted, LLC