Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/12/2007, 12:14
Avatar de Larc
Larc
 
Fecha de Ingreso: octubre-2003
Ubicación: Mexico
Mensajes: 259
Antigüedad: 20 años, 6 meses
Puntos: 0
Modificar menu tipo Mac OSX

Hola de nuevo a todos, consegui un ejemplo de un menu tipo Mac OSX esta genial .


Funciona a la perfección , Pero me gustaria hacerle una modificacion al codigo y no se como .


Aqui va el problema :

El menu tiene 10 opciones, cada una con nombre de instancia 1, 2, 3...10 , en el codigo usa una variable llamada i para relacionar el numero de cada opcion del menu.

El codigo completo es este:

Código:
onClipEvent(load){
	_quality = "BEST";
	var margin = 2;			// tray margin
	var min = 32;			// icon size at its smallest
	var max = 72;			// icon size at its largest
	var span = 2.25 * min;		// radius of influence
	var spacing = min + 1;	// icon spacing
	var n = 10;				// number of icons
	var speed = 0.25;

	var _MC = Math.cos;
	var _MS = Math.sin;
	var _s = max - min;
	var state = 0;
	var piSpan = Math.PI / span;
	var center = new Array();
	for(i = 1; i <= n; i++){
		this[i]._y = - margin;
		center[i] = (2 * i - n - 1) * spacing / 2;
	}
	tray._height = min + 2 * margin;
	this._alpha = 0;
}

onClipEvent(enterFrame){
	if(this._alpha < 100) this._alpha += 10;
	if (state == 0 || state == 1) temp = false; else temp = true;
	if(inside) state = Math.min(1, state + 0.2); else state = Math.max(0, state - 0.2);
	if(x != _xmouse || y != _ymouse || temp) {

		var x = _xmouse;
		var y = _ymouse;
		var x1 = tray._x;
		var x2 = x1 + tray._width;

		if(!temp){
			if( x < x1 || x > x2 || Math.abs(y) > altitude ) inside = false; else inside = true;
		}

		var altitude = min + 2 * margin + _s * state;

		for(i = 1; i <= n; i++){
			lo = center[i] - state * span;
			hi = center[i] + state * span;

			if(x <= lo) iX = hi;	// mouse on the left, icon to the right
			if(x >= hi) iX = lo;	// mouse on the right, icon to the left

			if(x > lo && x < hi) {		// icon is influenced by mouse
				fi = piSpan * (hi - x);					 		// 0..2pi
				cfi = _MC(fi / 2);								// 1..-1
				sfi = _MS(fi) / 20;								// horizontal compensation
				iX = center[i] - state * span * (cfi + sfi);	// centrum ± span
				iSize = _s * (1 - cfi * cfi);		 			// icon resize
			} 
			else iSize = 0;
			_scale = 100 * (min + state * iSize)/128;
			this[i]._xscale = this[i]._yscale = _scale;
			this[i]._x = iX;
		}
		tray._width = this[n]._x - this[1]._x + this[1]._width/2 + this[n]._width/2 + 2 * margin;
		tray._x = this[1]._x - this[1]._width/2 - margin;
	}
}

La modificacion que quiero hacer es, que en lugar de usar un numero de instancia en cada opcion del menu, use un nombre; por ejemplo:

que la opcion 1, se llama btn1.

he intentado modificar el codigo en las opciones donde se utiliza la variable i haciendo esto:

"btn" + i

Pero no consigo resultados ni errores, solo no ejecuta el menu.


Como podria modificar el codigo de tal manera que pueda usar nombres de instancia como btn1, btn2, btn3..... btn10 .


les dejo el meno para que lo chequen y lo puedan tener:

***.leonardosco.com/Menu_tipo_MAC.zip

De antemano muchas gracias a todos los que leen el post
__________________
Quien parte de las sombras y se levanta como un muerto brillando como una estrella sobre èl (towlen), entre la oscuridad congelante y la luz.
LÄRÇ :serio: