Comunidad de diseño web y desarrollo en internet online

ayuda con botones dinamicos!

Citar            
MensajeEscrito el 01 Ene 2008 08:07 pm
ESTE ES MI CODIGO

with(botonera){
boton1.onRelease = function(){
boton2.enabled = boton3.enabled = boton4.enabled = true;
this.enabled =false;
if(this.enabled==false) this.gotoAndStop("_seleccion");
}

boton2.onRelease = function(){
this.enabled =false;
boton3.enabled = boton4.enabled = boton1.enabled = true;
if(this.enabled==false) this.gotoAndStop("_seleccion");
}

boton3.onRelease = function(){
this.enabled =false;
boton1.enabled = boton2.enabled = boton4.enabled = true;
if(this.enabled==false) this.gotoAndStop("_seleccion");
}

boton4.onRelease = function(){
this.enabled =false;
boton1.enabled = boton2.enabled = boton3.enabled = true;
if(this.enabled==false) this.gotoAndStop("_seleccion");
}
}


dos preguntas:
1)puedo resumir todo ese codigo con algun ciclo o algo..porq no se me ocurre.
2) con esta linea if(this.enabled==false) this.gotoAndStop("_seleccion"); logro destacar el boton seleccionado pero mi problema es como hacer que vuelva a su estado normal cuando selecciono otro.porque si selecciono otro el q ya estaba seleccionado no vuelve a su estado normal.


grax!

Por usuaria

6 de clabLevel



Genero:Femenino  

msie7
Citar            
MensajeEscrito el 01 Ene 2008 09:18 pm
mira aqui

Código :

var cantidad:Number = 4;
for (var i:Number = 0; i<=cantidad; i++) {
   //aqui ubicas donde estan tusbotones
   //-------------------------------------------------------------------------
   var boton_mc:MovieClip = _root["boton"+i];
   //-------------------------------------------------------------------------
   boton_mc.onRelease = function() {
      habilitar();
      reestablece();
      this.enabled = false;
      this.useHandCursor = false;
      this.gotoAndStop(2);
   };
}
function habilitar() {
   for (var i:Number = 0; i<=cantidad; i++) {
      var boton_mc:MovieClip = _root["boton"+i];
      boton_mc.useHandCursor = true;
      boton_mc.enabled = true;
   }

}
function reestablecer() {
   for (var i:Number = 0; i<=cantidad; i++) {
      var boton_mc:MovieClip = _root["boton"+i];
      boton_mc.gotoAndStop(1);
   }
}



en un fla "nuevo" , crea tus cuatro botones (que en realidad supongo son movieclips por el codigo que tienes), dentro de esos botones tendras dos frames el primero sera para el estado normal y el otro cuando se de click (recuerda ponerles un stop() e iluminar cada frame de un color diferente).

nota: si metes mas botones solo cambia la cantidad del code.

Por DiegoAzul

376 de clabLevel



 

Mx

firefox
Citar            
MensajeEscrito el 01 Ene 2008 09:33 pm
falto una r asi esta bien:


Código :

var cantidad:Number = 4;
for (var i:Number = 0; i<=cantidad; i++) {
   //aqui ubicas donde estan tusbotones
   //-------------------------------------------------------------------------
   var boton_mc:MovieClip = _root["boton"+i];
   //-------------------------------------------------------------------------
   boton_mc.onRelease = function() {
      habilitar();
      reestablecer();
      this.enabled = false;
      this.useHandCursor = false;
      this.gotoAndStop(2);
   };
}
function habilitar() {
   for (var i:Number = 0; i<=cantidad; i++) {
      var boton_mc:MovieClip = _root["boton"+i];
      boton_mc.useHandCursor = true;
      boton_mc.enabled = true;
   }

}
function reestablecer() {
   for (var i:Number = 0; i<=cantidad; i++) {
      var boton_mc:MovieClip = _root["boton"+i];
      boton_mc.gotoAndStop(1);
   }
}

Por DiegoAzul

376 de clabLevel



 

Mx

firefox
Citar            
MensajeEscrito el 01 Ene 2008 11:26 pm
pongo todo el codigo porq no me anduvo lo de la rta anterior..por ahi es algo que tengo que modificar del resto..

var labels:Array = Array("servicios","portfolio","clientes","contacto");
var botonera:MovieClip = this.createEmptyMovieClip("botonera", getNextHighestDepth());
botonera._y = 400;
botonera._x = 600;


botonera.attachMovie("boton","boton", botonera.getNextHighestDepth ());
for(i=1;i <= labels.length; i++){

var auxbtn:MovieClip = botonera.boton.duplicateMovieClip("boton"+i,botonera.getNextHighestDepth());
auxbtn._y = botonera["boton"+(i-1)]._y +botonera["boton"+(i-1)]._height +20;
auxbtn.caja.text = labels[i-1];
auxbtn.bandera = true;
auxbtn.onRollOver = function(){this.gotoAndPlay("_over");}

auxbtn.onPress = function(){

var seccion =this.caja.text+".swf"
_root.contenedor.loadMovie(seccion);
}


with(botonera){

boton1.onRelease = function(){
boton2.enabled = boton3.enabled = boton4.enabled = true;
this.enabled =false;
if(this.enabled==false) this.gotoAndStop("_seleccion");
}

boton2.onRelease = function(){
this.enabled =false;
boton3.enabled = boton4.enabled = boton1.enabled = true;
if(this.enabled==false) this.gotoAndStop("_seleccion");
}

boton3.onRelease = function(){
this.enabled =false;
boton1.enabled = boton2.enabled = boton4.enabled = true;
if(this.enabled==false) this.gotoAndStop("_seleccion");
}

boton4.onRelease = function(){
this.enabled =false;
boton1.enabled = boton2.enabled = boton3.enabled = true;
if(this.enabled==false) this.gotoAndStop("_seleccion");
}

btn_1.onPress = function(){
var seccion = "universal.swf"
_root.contenedor.loadMovie(seccion);
boton1.enabled = boton2.enabled = boton3.enabled = boton4.enabled =true;
}

}
}

Por usuaria

6 de clabLevel



Genero:Femenino  

firefox

 

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