Comunidad de diseño web y desarrollo en internet online

Dimesiones de los movieclips

Citar            
MensajeEscrito el 02 Abr 2013 09:49 am
Tengo bastantes movieclips que contienen texturas. El tamaño de la textura es superior al del movieclip y tiene una máscara de recorte.
El caso es que necesito saber las dimensiones del objeto, y mc.width mc.height me está mostrando las dimensiones con la textura, que no coinciden con las mostradas en propiedades.

Siempre tengo el mismo problema y al final acabo haciendo algún apaño cutrongo. ¿Qué podría hacer para obtener su anchura y altura obviando el tamaño de la textura?

Gracias por la ayuda.

Por majalon

1 de clabLevel



 

firefox
Citar            
MensajeEscrito el 02 Abr 2013 02:36 pm
El ancho y alto de un MC se calcula según todo el contenido que tenga ... agrega la textura en un MC distinto, no en el mismo que quieres medir

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 02 Abr 2013 02:40 pm
El ancho y alto de un MC se calcula según todo el contenido que tenga ... agrega la textura en un MC distinto, no en el mismo que quieres medir

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 02 Abr 2013 05:59 pm
BuenAS:

Echa un vistazo a estas dos funciones:

Código ActionScript :

function getVisibleWidth (o:DisplayObject):Number {
  var bitmapDataSize:int = 2000;
  var bounds:Rectangle;
  var bitmapData:BitmapData = new BitmapData(bitmapDataSize, 
                                             bitmapDataSize, 
                                             true, 
                                             0);
  bitmapData.draw(o);
  bounds = bitmapData.getColorBoundsRect( 0xFF000000, 0x00000000, false );
  bitmapData.dispose(); 
  return bounds.x + bounds.width;
}
function getVisibleHeight (o:DisplayObject):Number {
  var bitmapDataSize:int = 2000;
  var bounds:Rectangle;
  var bitmapData:BitmapData = new BitmapData(bitmapDataSize, 
                                             bitmapDataSize,
                                             true,
                                             0);
  bitmapData.draw(o);
  bounds = bitmapData.getColorBoundsRect( 0xFF000000, 0x00000000, false );
  bitmapData.dispose(); 
  return bounds.y + bounds.height;
}

Son de Colin Moock. Puedes encontrar el artículo original con su explicación aquí.

Un saludo.

Por Lukánicos

Claber

468 de clabLevel



Genero:Masculino  

chrome
Citar            
MensajeEscrito el 03 Abr 2013 10:46 am
Muchas gracias, esa función me lo ha resuelto sin tener que retocar los MovieClips (que la verdad es que eran un porrón).

Por majalon

1 de clabLevel



 

firefox

 

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