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

Ayuda por favor!!! Códigoooo

Estas en el tema de Ayuda por favor!!! Códigoooo en el foro de Flash y Actionscript en Foros del Web. Antes de nada SALU2 a todos los forer@s. Este es el código lo q hace es hacer zoom sobre un mapamundi (con su correspondiente cambio ...
  #1 (permalink)  
Antiguo 26/07/2007, 12:26
 
Fecha de Ingreso: julio-2007
Mensajes: 3
Antigüedad: 16 años, 8 meses
Puntos: 0
Ayuda por favor!!! Códigoooo

Antes de nada SALU2 a todos los forer@s.
Este es el código lo q hace es hacer zoom sobre un mapamundi (con su correspondiente cambio de cursor). Cuando pinchas sobre tierra (countryfill) hace zoom (+) y cuando haces click sobre agua hace zoom (-).
El caso es q quiero adaptar el codigo para q sea un zoom de ida y vuelta, es decir, haces click zoom (+) sobre el punto señalado y haces otro click y volverías al punto inicial un zoom (-) negativo.
Pero el caso es no tengo ni idea de actionscript, y no se si será dificil o no.
SALU2 MACANU2


pri_width = mc_map._width;
pri_height = mc_map._height;
pointer._visible = 0;
//--CAMBIO EL PUNTERO DEL MOUSE
//--EN 1 ES MAS Y EN 2 ES MENOS
mc_map.map.countryFill.onRollOver = function() {
Mouse.hide();
startDrag(pointer, true);
pointer.gotoAndStop(1);
pointer._visible = 1;
};
mc_map.map.seaFill.onRollOver = function() {
Mouse.hide();
startDrag(pointer, true);
pointer.gotoAndStop(2);
pointer._visible = 1;
};
mc_map.map.countryFill.onRollOut = function() {
Mouse.show();
stopDrag();
pointer._visible = 0;
};
mc_map.map.seaFill.onRollOut = function() {
Mouse.show();
stopDrag();
pointer._visible = 0;
};
//--CUANDO SE SUELTA EL BOTON DEL MOUSE SOBRE LA TIERRA
//--ZOOM(+) Y SE CENTRA EL PUNTO EN EL QUE SE HIZO CLICK
incremento = 1.2;
mc_map.map.countryFill.onRelease = function() {
esteX = this._parent._parent._parent._xmouse/pri_width;
esteY = this._parent._parent._parent._ymouse/pri_height;
esteXmap = this._parent._parent._xmouse/pri_width;
esteYmap = this._parent._parent._ymouse/pri_height;
// mc_map._x = (60+((1-esteXmap)*(mc_map._width*incremento)))-(mc_map._width*incremento);
limiteX = ((pri_width/2)+((1-esteXmap)*(this._parent._parent._width*incremento) ))-(this._parent._parent._width*incremento);
limiteY = ((pri_height/2)+((1-esteYmap)*(this._parent._parent._height*incremento )))-(this._parent._parent._height*incremento);
if (pri_width-(this._parent._parent._width*incremento)>limiteX) {
limiteX = pri_width-(this._parent._parent._width*incremento);
}
if (pri_height-(this._parent._parent._height*incremento)>limiteY) {
limiteY = pri_height-(this._parent._parent._height*incremento);
}
if (limiteX>0) {
limiteX = 0;
}
if (limiteY>0) {
limiteY = 0;
}
mover_mapa(this._parent._parent, (this._parent._parent._xscale*incremento), limiteX, limiteY);
trace(this._parent._parent._xscale*incremento);
};
//--CUANDO SE SUELTA EL BOTON DEL MOUSE SOBRE EL AGUA
//--ZOOM(-) Y SE CENTRA EL PUNTO EN EL QUE SE HIZO CLICK
mc_map.map.seaFill.onRelease = function() {
esteX = this._parent._parent._parent._xmouse/pri_width;
esteY = this._parent._parent._parent._ymouse/pri_height;
esteXmap = this._parent._parent._xmouse/pri_width;
esteYmap = this._parent._parent._ymouse/pri_height;
// mc_map._x = (60+((1-esteXmap)*(mc_map._width*incremento)))-(mc_map._width*incremento);
limiteX = ((pri_width/2)+((1-esteXmap)*(this._parent._parent._width/incremento)))-(this._parent._parent._width/incremento);
limiteY = ((pri_height/2)+((1-esteYmap)*(this._parent._parent._height/incremento)))-(this._parent._parent._height/incremento);
if (pri_width-(this._parent._parent._width/incremento)>limiteX) {
limiteX = pri_width-(this._parent._parent._width/incremento);
}
if (pri_height-(this._parent._parent._height/incremento)>limiteY) {
limiteY = pri_height-(this._parent._parent._height/incremento);
}
if (limiteX>0) {
limiteX = 0;
}
if (limiteY>0) {
limiteY = 0;
}
if (this._parent._parent._xscale/incremento>=100) {
trace(this._parent._parent._xscale/incremento);
mover_mapa(this._parent._parent, (this._parent._parent._xscale/incremento), limiteX, limiteY);
} else {
mover_mapa(this._parent._parent, 100, limiteX, limiteY);
}
};
//--FUNCION PARA HACER ZOOM Y CENTRAR EL MAPA
mover_mapa = function (mc_name, escala, x, y) {
trace(x+"=="+y);
mov_speed = 4;
mc_name.onEnterFrame = function() {
// if (this._x>x) {
// this._x += (x-this._x)/mov_speed;
// } else {
this._x += (x-this._x)/mov_speed;
// }
// if (this._y>y) {
// this._y += (y-this._y)/mov_speed;
// } else {
this._y += (y-this._y)/mov_speed;
// }
if (this._xscale<escala) {
if (this._xscale<(escala-(0.1+(escala-this._xscale)/mov_speed))) {
this._xscale = this._yscale += (escala-this._xscale)/mov_speed;
} else {
this._xscale = this._yscale=escala;
trace(this._xscale);
delete mc_name.onEnterFrame;
}
}
if (this._xscale>escala) {
if (this._xscale>escala+0.1) {
this._xscale = this._yscale -= (this._xscale-escala)/mov_speed;
} else {
this._xscale = this._yscale=escala;
trace(this._xscale);
delete mc_name.onEnterFrame;
}
}
};
};
  #2 (permalink)  
Antiguo 26/07/2007, 13:34
 
Fecha de Ingreso: septiembre-2006
Mensajes: 1.193
Antigüedad: 17 años, 6 meses
Puntos: 30
Re: Ayuda por favor!!! Códigoooo

no te hare tu zoom pero te voya explicar que debes hacer:

supongamos que

ZoomMas
ZoomMenos

son tus funciones una hace un zoom + y otro -

Código:
var ZoomMas:String = "zoom mas";
var ZoomMenos:String = "zoom Menos";
lo que quieres es que con un solo click existan dos eventos posibles y esto lo haces con un contador:


Código:
var contador:Number = 0;
que verificara cuantos clicks estas haciendo ahora necesitas que este contador cree dos estados un positivo para el zoom +y el negativo para zoom -, esto lo haces con el operador "%" "resto". que te arrojara mediante contador%2;
un cero o un uno. y ya con eso verificas si hace un uno haga un zoomMas o si saca un cero un zoommenos.

Código:
this.onMouseDown = function() {

	contador++;
	var resto:Number = contador%2;

	if (resto != 0) {

		trace(ZoomMas);
	} else {

		trace(ZoomMenos);
	}
};

el codigo completo seria asi .

Código:
var ZoomMas:String = "zoom mas";
var ZoomMenos:String = "zoom Menos";

var contador:Number = 0;
this.onMouseDown = function() {

	contador++;
	var resto:Number = contador%2;

	if (resto != 0) {

		trace(ZoomMas);
	} else {

		trace(ZoomMenos);
	}
};
ahora intenta adaptarlo.

y procura poner en tu post el codigo entre las etiquetas code
  #3 (permalink)  
Antiguo 27/07/2007, 03:58
 
Fecha de Ingreso: julio-2007
Mensajes: 3
Antigüedad: 16 años, 8 meses
Puntos: 0
Re: Ayuda por favor!!! Códigoooo

Gracias por la ayuda intentaré apañarlo con lo q me has indicado
Código HTML:
pri_width = mc_map._width;
pri_height = mc_map._height;
pointer._visible = 0;
//--CAMBIO EL PUNTERO DEL MOUSE
//--EN 1 ES MAS Y EN 2 ES MENOS
mc_map.map.countryFill.onRollOver = function() {
	Mouse.hide();
	startDrag(pointer, true);
	pointer.gotoAndStop(1);
	pointer._visible = 1;
};
mc_map.map.seaFill.onRollOver = function() {
	Mouse.hide();
	startDrag(pointer, true);
	pointer.gotoAndStop(2);
	pointer._visible = 1;
};
mc_map.map.countryFill.onRollOut = function() {
	Mouse.show();
	stopDrag();
	pointer._visible = 0;
};
mc_map.map.seaFill.onRollOut = function() {
	Mouse.show();
	stopDrag();
	pointer._visible = 0;
};
//--CUANDO SE SUELTA EL BOTON DEL MOUSE SOBRE LA TIERRA
//--ZOOM(+) Y SE CENTRA EL PUNTO EN EL QUE SE HIZO CLICK
incremento = 1.2;
mc_map.map.countryFill.onRelease = function() {
	esteX = this._parent._parent._parent._xmouse/pri_width;
	esteY = this._parent._parent._parent._ymouse/pri_height;
	esteXmap = this._parent._parent._xmouse/pri_width;
	esteYmap = this._parent._parent._ymouse/pri_height;
	//	mc_map._x = (60+((1-esteXmap)*(mc_map._width*incremento)))-(mc_map._width*incremento);
	limiteX = ((pri_width/2)+((1-esteXmap)*(this._parent._parent._width*incremento)))-(this._parent._parent._width*incremento);
	limiteY = ((pri_height/2)+((1-esteYmap)*(this._parent._parent._height*incremento)))-(this._parent._parent._height*incremento);
	if (pri_width-(this._parent._parent._width*incremento)>limiteX) {
		limiteX = pri_width-(this._parent._parent._width*incremento);
	}
	if (pri_height-(this._parent._parent._height*incremento)>limiteY) {
		limiteY = pri_height-(this._parent._parent._height*incremento);
	}
	if (limiteX>0) {
		limiteX = 0;
	}
	if (limiteY>0) {
		limiteY = 0;
	}
	mover_mapa(this._parent._parent, (this._parent._parent._xscale*incremento), limiteX, limiteY);
	trace(this._parent._parent._xscale*incremento);
};
//--CUANDO SE SUELTA EL BOTON DEL MOUSE SOBRE EL AGUA
//--ZOOM(-) Y SE CENTRA EL PUNTO EN EL QUE SE HIZO CLICK
mc_map.map.seaFill.onRelease = function() {
	esteX = this._parent._parent._parent._xmouse/pri_width;
	esteY = this._parent._parent._parent._ymouse/pri_height;
	esteXmap = this._parent._parent._xmouse/pri_width;
	esteYmap = this._parent._parent._ymouse/pri_height;
	//	mc_map._x = (60+((1-esteXmap)*(mc_map._width*incremento)))-(mc_map._width*incremento);
	limiteX = ((pri_width/2)+((1-esteXmap)*(this._parent._parent._width/incremento)))-(this._parent._parent._width/incremento);
	limiteY = ((pri_height/2)+((1-esteYmap)*(this._parent._parent._height/incremento)))-(this._parent._parent._height/incremento);
	if (pri_width-(this._parent._parent._width/incremento)>limiteX) {
		limiteX = pri_width-(this._parent._parent._width/incremento);
	}
	if (pri_height-(this._parent._parent._height/incremento)>limiteY) {
		limiteY = pri_height-(this._parent._parent._height/incremento);
	}
	if (limiteX>0) {
		limiteX = 0;
	}
	if (limiteY>0) {
		limiteY = 0;
	}
	if (this._parent._parent._xscale/incremento>=100) {
		trace(this._parent._parent._xscale/incremento);
		mover_mapa(this._parent._parent, (this._parent._parent._xscale/incremento), limiteX, limiteY);
	} else {
		mover_mapa(this._parent._parent, 100, limiteX, limiteY);
	}
};
//--FUNCION PARA HACER ZOOM Y CENTRAR EL MAPA
mover_mapa = function (mc_name, escala, x, y) {
	trace(x+"=="+y);
	mov_speed = 4;
	mc_name.onEnterFrame = function() {
		// if (this._x>x) {
		// this._x += (x-this._x)/mov_speed;
		// } else {
		this._x += (x-this._x)/mov_speed;
		// }
		// if (this._y>y) {
		// this._y += (y-this._y)/mov_speed;
		// } else {
		this._y += (y-this._y)/mov_speed;
		// }
		if (this._xscale<escala) {
			if (this._xscale<(escala-(0.1+(escala-this._xscale)/mov_speed))) {
				this._xscale = this._yscale += (escala-this._xscale)/mov_speed;
			} else {
				this._xscale = this._yscale=escala;
				trace(this._xscale);
				delete mc_name.onEnterFrame;
			}
		}
		if (this._xscale>escala) {
			if (this._xscale>escala+0.1) {
				this._xscale = this._yscale -= (this._xscale-escala)/mov_speed;
			} else {
				this._xscale = this._yscale=escala;
				trace(this._xscale);
				delete mc_name.onEnterFrame;
			}
		}
	};
};
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:57.