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

Modificar un codigo

Estas en el tema de Modificar un codigo en el foro de Flash y Actionscript en Foros del Web. Mi consulta es por un menu. El codigo envia el inicio del submenu de acuerdo a la altura del menu. El "problema" se da cuando ...
  #1 (permalink)  
Antiguo 27/07/2006, 05:46
 
Fecha de Ingreso: julio-2006
Mensajes: 6
Antigüedad: 17 años, 8 meses
Puntos: 0
Modificar un codigo

Mi consulta es por un menu. El codigo envia el inicio del submenu de acuerdo a la altura del menu. El "problema" se da cuando hay mas de 10 menúes (es decir, de dos digitos) ya que para por ejemplo 15, toma el primer dígito (1), y de esa forma se visualiza el submenu 1, y no el submenu 15.
Lo que necesitaría es que "lea" los dos digitos, para que acceda al submenu correspondiente. Por las dudas envio el codigo, como ejemplo.

Muchas gracias !!!

Código:
this._visible=false; 
// Declaración de arrays para crear menú y submenu 
var menu_array:Array = newArray; 
var subMenu1_array:Array = newArray; 
var subMenu2_array:Array = newArray; 
var subMenu3_array:Array = newArray; 
var subMenu4_array:Array = newArray; 
var subMenu5_array:Array = newArray; 
var subMenu6_array:Array = newArray; 
var subMenu7_array:Array = newArray; 
var subMenu8_array:Array = newArray; 
var subMenu9_array:Array = newArray; 
var subMenu10_array:Array = newArray; 
var subMenu11_array:Array = newArray; 
var subMenu12_array:Array = newArray; 
var subMenu13_array:Array = newArray; 
var subMenu14_array:Array = newArray; 
var subMenu15_array:Array = newArray; 
var subMenu16_array:Array = newArray; 
var subMenu17_array:Array = newArray; 
var subMenu18_array:Array = newArray; 
menu_array = ["TextoMenu", "TextoMenu", "TextoMenu", "TextoMenu", "TextoMenu", "TextoMenu", "TextoMenu", "TextoMenu", "TextoMenu", "TextoMenu", "TextoMenu", "TextoMenu", "TextoMenu", "TextoMenu", "TextoMenu", "TextoMenu", "TextoMenu", "TextoMenu"]; 
subMenu1_array = ["Texto1,nombre1", "Texto2,nombre2"]; 
subMenu2_array = ["Texto1,nombre1", "Texto2,nombre2"]; 
subMenu3_array = ["Texto1,nombre1", "Texto2,nombre2"]; 
subMenu4_array = ["Texto1,nombre1", "Texto2,nombre2"]; 
subMenu5_array = ["Texto1,nombre1", "Texto2,nombre2"]; 
subMenu6_array = ["Texto1,nombre1", "Texto2,nombre2"]; 
subMenu7_array = ["Texto1,nombre1", "Texto2,nombre2"]; 
subMenu8_array = ["Texto1,nombre1", "Texto2,nombre2"]; 
subMenu9_array = ["Texto1,nombre1", "Texto2,nombre2"]; 
subMenu10_array = ["Texto1,nombre1", "Texto2,nombre2"]; 
subMenu11_array = ["Texto1,nombre1", "Texto2,nombre2"]; 
subMenu12_array = ["Texto1,nombre1", "Texto2,nombre2"]; 
subMenu13_array = ["Texto1,nombre1", "Texto2,nombre2"]; 
subMenu14_array = ["Texto1,nombre1", "Texto2,nombre2"]; 
subMenu15_array = ["Texto1,nombre1", "Texto2,nombre2"]; 
subMenu16_array = ["Texto1,nombre1", "Texto2,nombre2"]; 
subMenu17_array = ["Texto1,nombre1", "Texto2,nombre2"]; 
subMenu18_array = ["Texto1,nombre1", "Texto2,nombre2"]; 


subMenu = function (subNumber){ 
var tempArray= this["subMenu"+subNumber+"_array"]; 
var tempMc= this["menu"+subNumber+"_mc"]; 
this.createEmptyMovieClip("sub_mc",100); 
this.sub_mc._alpha = 0; 
for(i=0;i<tempArray.length;i++){ 
//trace("registro n: "+i+" "+tempArray[i]+newline) 
var tempSM=sub_mc.attachMovie("subMenu_mc","_mc"+(i+1),(i+1)); 
var tmpIndex:String = tempArray[i]; 
var tmpSubArray:Array = tmpIndex.split(","); 
tempSM.titulo_mc.titulo_txt.text = tmpSubArray[0]; 
tempSM.destino = tmpSubArray[1]; 
tempSM.opcion = tmpSubArray[2]; 
tempSM._y += sub_mc._height; 
tempSM.bg_mc.onRollOver = function () { 
this._parent._parent._parent.desplegado=true; 
this._parent.titulo_mc.enabled = true; 
} 
if (tempSM.opcion == false or tempSM.opcion == undefined) { 
tempSM.titulo_mc.onPress = function () { 
_level0.gotoAndStop(this._parent.destino); 
this._parent._parent._parent._visible = false; 
this._parent._parent.onEnterFrame = undefined; 
_level0.indice_btn.gotoAndStop("btn_sinDespl"); 
} 
} else { 

} 
tempSM.titulo_mc.onRollOver = function () { 
_level0.destino = this.destino; 
_level0.destino1=undefined; 
} 
if (tmpSubArray[2]==undefined) { 
tempSM.intro_btn._visible = false; 
tempSM.captivate_btn._visible = false; 
} 
} 
sub_mc._x=tempMc._x+ tempMc._width; 
sub_mc._y=tempMc._y-(sub_mc._height); 
var topLevel: Number = sub_mc._y+tempSM._height; 
var botLevel: Number = sub_mc._y+sub_mc._height+tempSM._height; 
var lefLevel: Number = sub_mc._x; 
var rigLevel: Number = sub_mc._x+sub_mc._width; 
this.sub_mc.onEnterFrame = function () { 
//trace ("MOUSE: "+ _ymouse + " >>> T:"+ topLevel +" >>> B: " +botLevel) 
if (this._alpha < 100) { 
this._alpha+=10; 
} 
if (this._parent.desplegado==true) { 
if ((_xmouse >=lefLevel and _xmouse <=rigLevel)and (_ymouse >=topLevel and _ymouse <=botLevel)){ 
this._visible = true; 
} else { 
this._visible = false; 
this._parent._parent.desplegado=false; 
this.onEnterFrame = undefined; 
} 
} 
} 
//trace("submenu y: "+sub_mc._y+" botn y: "+tempMc._y) 
} 

// Creacion de menú 
for (i=1; i<=18; i++) { 
var tempMenu:MovieClip = this["menu"+i+"_mc"]; 
tempMenu.numero_txt.text = i; 
tempMenu.titulo_txt.text = menu_array[i-1]; 
tempMenu.onPress=function(){ 
var tempNumber:String=this._name; 
tempNumber=tempNumber.slice(4,5) 
subMenu(tempNumber); 
this._parent.desplegado = false; 
} 
}
  #2 (permalink)  
Antiguo 29/07/2006, 11:10
 
Fecha de Ingreso: julio-2006
Mensajes: 6
Antigüedad: 17 años, 8 meses
Puntos: 0
Le doy un ultimo UP a este thread para ver si alguien me puede ayudar en esto, muchas gracias de igual forma...
  #3 (permalink)  
Antiguo 29/07/2006, 14:36
 
Fecha de Ingreso: enero-2005
Ubicación: culiacan, sinaloa, mexico
Mensajes: 97
Antigüedad: 19 años, 3 meses
Puntos: 0
for (i=1; i<=18; i++) {
var tempMenu:MovieClip = this["menu"+i+"_mc"];
tempMenu.numero_txt.text = i;
tempMenu.titulo_txt.text = menu_array[i-1];
tempMenu.onPress=function(){
var tempNumber:String=this._name;
if (i<9) {
tempNumber = tempNumber.slice(4, 5);
} else {
tempNumber = tempNumber.slice(4, 6);
}
trace(tempNumber);
subMenu(tempNumber);
this._parent.desplegado = false;
}
}

ahi esta tu solucion, espero te sirva si no mandame un mensaje, pero a mi me funciono. solo puse un if, si "i" era menor que 9 te muestra un digito, pero si era mayor de nueve te muestra 2digitos
  #4 (permalink)  
Antiguo 30/07/2006, 07:44
 
Fecha de Ingreso: julio-2006
Mensajes: 6
Antigüedad: 17 años, 8 meses
Puntos: 0
Antes que nada gracias por la respuesta, lo he probrado y funciona perfectamente en la primer vez que se aprieta un boton, pero si aprietas un segundo, tercer, etc boton, ya aparece nuevamente el error anterior.
  #5 (permalink)  
Antiguo 30/07/2006, 23:02
 
Fecha de Ingreso: enero-2005
Ubicación: culiacan, sinaloa, mexico
Mensajes: 97
Antigüedad: 19 años, 3 meses
Puntos: 0
for (i=1; i<=18; i++) {
var tempMenu:MovieClip = this["menu"+i+"_mc"];
tempMenu.numero_txt.text = i;
tempMenu.id = i;
tempMenu.titulo_txt.text = menu_array[i-1];
tempMenu.onPress = function() {
var tempNumber:String = this._name;
if (this.id<9) {
tempNumber = tempNumber.slice(4, 5);
} else {
tempNumber = tempNumber.slice(4, 6);
}
trace(this.id);
trace(tempNumber);
subMenu(tempNumber);
this._parent.desplegado = false;
};
}


hermano, ahi esta la solucion, "again", solo le agregue un id a cada boton para identificarlo, ahora si su id era menor a 10 toma un solo dijito, si era mayor toma dos digitos. P.D. podrias evitarte hacer todo ese show del menu con algo mas sencillo, pero yo solo me digno a contestar las dudas.
  #6 (permalink)  
Antiguo 31/07/2006, 07:45
 
Fecha de Ingreso: julio-2006
Mensajes: 6
Antigüedad: 17 años, 8 meses
Puntos: 0
La verdad, no me alcanzan las palabras para agradecerte. Y es verdad, coincido en que es una manera un poco rebuscada para hacer un menu, pero debo utilizarlo si o si. Tu codigo funciona perfectamente, lo unico que he cambiado es this.id<9 por this.id<10, porque sino no se incluia al boton 9. Otra vez muchas gracias !!
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 19:03.