Foros del Web » Creando para Internet » Flash y Actionscript »

centrar imagen en movieclip

Estas en el tema de centrar imagen en movieclip en el foro de Flash y Actionscript en Foros del Web. Tengo un slideshow en actionscript. Logré que las imagenes aparecieran en un lugar específico del escenario con el código: imagen1._x = 50; imagen1._y = 80; ...
  #1 (permalink)  
Antiguo 02/08/2007, 10:44
 
Fecha de Ingreso: mayo-2002
Mensajes: 148
Antigüedad: 21 años, 11 meses
Puntos: 0
centrar imagen en movieclip

Tengo un slideshow en actionscript.

Logré que las imagenes aparecieran en un lugar específico del escenario con el código:
imagen1._x = 50;
imagen1._y = 80;
imagen2._x = 50;
imagen2._y = 80;

Como ahora tengo imagenes verticales e imagenes apaisadas, quiero hacer lo mismo pero que las imagenes se carguen en el centro de la peli.
probé este código pero no funciona:
this._x = (Stage._width-imagen1._width)/2;
this._y = (Stage._height-imagen1._height)/2;
this._x = (Stage._width-imagen2._width)/2;
this._y = (Stage._height-imagen2._height)/2;

y me dice que la propiedad "_width" y "_height" no existen.

Probé así y tampoco funciona:
this._x = (Stage.width-imagen2.width)/2;
this._y = (Stage.height-imagen2.height)/2;
this._x = (Stage.width-imagen1.width)/2;
this._y = (Stage.height-imagen1.height)/2;

lo ignora y alinea en 0,0.

S.O.S.
  #2 (permalink)  
Antiguo 02/08/2007, 13:26
 
Fecha de Ingreso: mayo-2002
Mensajes: 148
Antigüedad: 21 años, 11 meses
Puntos: 0
Re: centrar imagen en movieclip

Probé así:
imagen1._x = Stage.width/2;
imagen1._y = Stage.height/2;
imagen2._x = Stage.width/2;
imagen2._y = Stage.height/2;

y coloca el angulo superior de la foto en ese punto...

Quizás con todo el código del slideshow alguien se anime...

Ahí va en AS:

info = new LoadVars();
info.load("imagenes.txt");

info.onLoad = function(leido) {
if(leido) {
fotos = new Array();
for( i=1; i<=info.total; i++ ) {
fotos[i] = this["foto"+i];
}

_root.createEmptyMovieClip("imagen1",10);
_root.createEmptyMovieClip("imagen2",11);

imagen1._x = Stage.width/2;
imagen1._y = Stage.height/2;
imagen2._x = Stage.width/2;
imagen2._y = Stage.height/2;


im = 1;
imagen1.loadMovie("images/" + fotos[im]);

im++;
imagen2.loadMovie("images/" + fotos[im]);
imagen2._alpha = 0;

disol = 10;
fijo = 35;
count_d = 0;
count_f = 0;

curr_mc = 1;

onEnterFrame = function () {
if( curr_mc == 1 ) {
count_f ++;
if( count_f >= fijo ) {
curr_mc = 2;
cambio = "IN";
}
}

if( curr_mc == 2 ) {
if( cambio == "IN" ){
imagen2._alpha += 100/disol;
if( imagen2._alpha >= 100 ) {
imagen2._alpha = 100;
cambio = "FIJO";
count_f = 0;
im++;
if( im == fotos.length )
im = 1;
}
imagen1.loadMovie("images/" + fotos[im]);
}
}

if( cambio == "FIJO" ) {
count_f++;
if( count_f >= fijo ) {
cambio = "OUT";
}
}

if( cambio == "OUT" ) {
imagen2._alpha -= 100/disol;
if( imagen2._alpha <= 0 ) {
imagen2._alpha = 0;
curr_mc = 1;
count_f = 0;
im++;
if( im == fotos.length ) {
im = 1;
}
imagen2.loadMovie("images/" + fotos[im]);
}
}
}
}
}
}

Ahi va imagenes.txt:

foto1=01.jpg&foto2=02.jpg&foto3=03.jpg&foto4=04.jp g&foto5=05.jpg&foto6=06.jpg&total=6
  #3 (permalink)  
Antiguo 02/08/2007, 13:43
 
Fecha de Ingreso: septiembre-2006
Mensajes: 1.193
Antigüedad: 17 años, 6 meses
Puntos: 30
Re: centrar imagen en movieclip

no vi todo tu codigo pero

esta parte es asi:

Código:
this._x = (Stage.width-imagen1._width)/2;
this._y = (Stage.height-imagen1._height)/2;
this._x = (Stage.width-imagen2._width)/2;
this._y = (Stage.height-imagen2._height)/2;
en Stage.width es sin guion-bajo"_" y todos los demas Stages´s
  #4 (permalink)  
Antiguo 03/08/2007, 08:36
 
Fecha de Ingreso: mayo-2002
Mensajes: 148
Antigüedad: 21 años, 11 meses
Puntos: 0
Re: centrar imagen en movieclip

Gracias Rizzo por tu interes, pero lamentablemente no funciona .

Continua ignorando la linea y colocando la imagen en el angulo de arriba.

Probé tambien
this._x = (imagen1._width)/2;
this._y = (imagen1._height)/2;
this._x = (imagen2._width)/2;
this._y = (imagen2._height)/2;
a ver si el problema estaba en la resta y continua colocando la imagen en el angulo de arriba.

Probé tambien
imagen1._x = (imagen1._width)/2;
imagen1._y = (imagen1._height)/2;
imagen1._x = (imagen2._width)/2;
imagen1._y = (imagen2._height)/2;
a ver si el problema estaba en el this y continua colocando la imagen en el angulo de arriba.

Probé tambien
imagen1._x = (Stage.width)/2;
imagen1._y = (Stage.height)/2;
imagen1._x = (Stage.width)/2;
imagen1._y = (Stage.height)/2;
y coloca el angulo superior de la foto en el centro de la peli
(obtiene el dato de la medida del escenario con éxito)
Con esto pensé: ahora hago la resta del ancho de la imagen y listo.
Entonves probé:
imagen1._x = (Stage.width-imagen1._width)/2;
imagen1._y = (Stage.height-imagen1._height)/2;
imagen2._x = (Stage.width-imagen2._width)/2;
imagen2._y = (Stage.height-imagen2._height)/2;
y coloca el angulo superior de la foto en el centro de la peli

Entonces probé (de puro insistente nomás):
this.imagen1._x = (Stage.width-imagen1._width)/2;
this.imagen1._y = (Stage.height-imagen1._height)/2;
this.imagen2._x = (Stage.width-imagen2._width)/2;
this.imagen2._y = (Stage.height-imagen2._height)/2;
y coloca el angulo superior de la foto en el centro de la peli

Discupen la falta de conocimiento en programación, soy diseñadora,
pero me da la impresión de que el dato que no logro obtener es el ancho de la imagen,
y no tengo idea de que mas probar...

Cualquier ayudita es bienvenida...!!!!



Última edición por vale; 03/08/2007 a las 09:18
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 07:52.