Comunidad de diseño web y desarrollo en internet online

Posicíon en función del formato de la imagen

Citar            
MensajeEscrito el 17 Jul 2008 03:46 pm
Tengo una galeria de imagenes ( miniaturas ) que, cuando clicadas, abren en otra ventana con un tamaño mas grande.
Mi problema es que algunas son en formato retrato ( vertical) y otras en paisaje ( apaisadas, horizontal). Es posible definir la posición de esta imagen en función del formato?
Las que son verticales debería quedar con un x, y y las horizontales en otro.

Desde ya muchas gracias. Claudio

Por Ishkandar

Claber

303 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 17 Jul 2008 05:10 pm
Lo puedes definir cuando termina de cargar, es decir haces un preload, cuando termina de cargar tomas el tamaño y luego decides que hacer según sea apaisado o vertical

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 18 Jul 2008 11:59 pm
Jorge, entendí todo menos cómo capturar las dimensiones de width e heigth de la imagen o swf cargado.

Por Ishkandar

Claber

303 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 19 Jul 2008 09:27 pm
Ok, aquí un par de turinas que cargan la imágen y la reescalan, las hice para esta galería http://www.flash-db.com/Tutorials/Gallery/, por lo que hay cosas que no vienen a cuento, pero lo principal está ahí. Son un par de métodos de la clase holder

Código :

/**
   *  Load big images
   *  @param who name of the image   
   */
   public function loadImage (who : String) : Void   {         
         //Create container just once for loading big photos
         if(!foto) foto = this._parent.createEmptyMovieClip("foto", 1)                               
         foto.loadMovie ("photos/orig/"+ who)
         foto._visible = false         
         preload._visible = true   
         //preloading
         this.onEnterFrame = function ()
         {         
            var perc = Math.round(foto.getBytesLoaded()/foto.getBytesTotal()*100);            
            preload.barra._width = perc
            foto._visible = false
            if (perc >= 100 && foto.getBytesLoaded () > 1 && foto._width > 1)
            {
               delete this.onEnterFrame
               preload._visible = false
               var dim = checkSize(foto._width, foto._height)               
               resize (dim.w, dim.h)
               //assign contextMenu 
               foto.menu = cmMenu
               //Saves image name for contextMenu
               foto.image = who
               //enables now
            }
      }      
   }
   /**
   *  Checkif the size of image overpass max limits
   *  @param w width of the image
   *  @param h heigth of the image   
   */
   private function checkSize(w:Number, h:Number):Object{      
      if(h<=maxHeight && w<=maxWidth) {
         return {h:h, w:w}
      } else { //recalculate dimensions, overpass boundaries         
         var orientation =(w>h)?"w" : "h"
         if(orientation=="h"){
            var per = int((maxHeight*100)/h)
            var newWidth = int((w*per)/100)
            return {h:maxHeight, w:newWidth}
         } else {
            var per = int((maxWidth*100)/w)
            var newHeight = int((h*per)/100)
            return {h:newHeight, w:maxWidth}            
         }
      }
   }


Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 19 Jul 2008 09:29 pm
Ooops, no me di cuenta que estoy en el foro de AS3 ... bueno, pasar este ejemplo no es tan difícil, tendrás que usar un Loader en vez de un loadMovie, y en vez de un onEnterFrame, agregas un listener al evento complete o init, inténtalo

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 21 Jul 2008 01:45 pm
Jorge hice así:

var container:Sprite = new Sprite();
addChild(container);

var pictLdr:Loader = new Loader();
pictLdr.load(new URLRequest("jpg/carro1.jpg"));
pictLdr.contentLoaderInfo.addEventListener(Event.COMPLETE, pictLdr_COMPLETE);

function pictLdr_COMPLETE(event:Event):void
{
container.addChild(pictLdr.content);
if ( container.width > container.height )
{
trace ( "paisaje" );
}
else
{
trace ( "retrato" );
}
trace( container.width );
trace ( container.height );
}

Por Ishkandar

Claber

303 de clabLevel



Genero:Masculino  

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.