Comunidad de diseño web y desarrollo en internet online

como corregir codigo

Citar            
MensajeEscrito el 26 Jun 2007 03:41 pm
Que tal

Necesito una vez mas su ayuda para esto.

Resulta que siempre estoy escribiendo el codigo para mis botones con la siguiente sintaxis:

btn_01_cirugia.onRollOver = function(){
this.gotoAndPlay(2);
}
btn_01_cirugia.onRollOut = function(){
this.gotoAndPlay(11);
}
btn_01_cirugia.onRelease = function(){
gotoAndStop(1);
}

/*----------------- btn_02-------------------*/


btn_01_minima.onRollOver = function(){
this.gotoAndPlay(2);
}
btn_01_minima.onRollOut = function(){
this.gotoAndPlay(11);
}
btn_01_minima.onRelease = function(){
gotoAndStop(2);
}

/*----------------- btn_03-------------------*/


btn_01_est.onRollOver = function(){
this.gotoAndPlay(2);
}
btn_01_est.onRollOut = function(){
this.gotoAndPlay(11);
}
btn_01_est.onRelease = function(){
gotoAndStop(3);
}

/*----------------- btn_04-------------------*/


btn_01_dre.onRollOver = function(){
this.gotoAndPlay(2);
}
btn_01_dre.onRollOut = function(){
this.gotoAndPlay(11);
}
btn_01_dre.onRelease = function(){
gotoAndStop(4);
}

/*----------------- btn_05-------------------*/


btn_01_geles.onRollOver = function(){
this.gotoAndPlay(2);
}
btn_01_geles.onRollOut = function(){
this.gotoAndPlay(11);
}
btn_01_geles.onRelease = function(){
gotoAndStop(5);
}


Entonces me gustaria Poder escribir lo mismo pero en menos codigo, no se si me explico, supongamos que tenga 20 botones, seria una lata hacer 20 veces el codigo de onRollOver onRelease onRollOut para cada Uno de los Btn.

Como puedo hacer solo, no se, una vez escribir onRollOver onRelease onRollOut para los 20 btn por ejemplo.

Gracias desde Ya!

Por chaleco

22 de clabLevel



 

firefox
Citar            
MensajeEscrito el 26 Jun 2007 04:55 pm
1.- el código va entre etiquetas [ code ]Mi código [ /code ]
2.- Utiliza prottipos

Código :

MovieClip.prototype.botoncito=function(){
this.onRollOver = function(){
this.gotoAndPlay(2);
}
this.onRollOut = function(){
this.gotoAndPlay(11);
}
this.onRelease = function(){
gotoAndStop(5);
}
}
btn_01_geles.botoncito();
btn_02_geles.botoncito();
btn_03_geles.botoncito();
btn_04_geles.botoncito();
btn_05_geles.botoncito();

Por bryanisimo

664 de clabLevel



Genero:Masculino  

Geek

firefox
Citar            
MensajeEscrito el 26 Jun 2007 05:23 pm
La ultima pregunta

excelente ejemplo

Como lo puedo hacer para que, en vez de que cargen siempre como

gotoAndStop(5);

se vayan cargando en los frames 1, 2, 3 ,4 ,5 6, 7

es decir

btn_01_geles al frame 1
btn_02_geles al frame 2
btn_03_geles al frame 3
btn_04_geles al frame 3
btn_05_geles al frame 3

y que el que este activo este enabled = false


Gracias por el Post

Por chaleco

22 de clabLevel



 

firefox
Citar            
MensajeEscrito el 26 Jun 2007 10:23 pm

Código :

MovieClip.prototype.botoncito=function(fotograma:Number):void{
   this.enabled = false
   this.onRollOver = function(){
      this.gotoAndPlay(2);
   }
   this.onRollOut = function(){
      this.gotoAndPlay(11);
   }
   this.onRelease = function(){
      gotoAndStop(fotograma);
   }
}
btn_01_geles.botoncito(1);
btn_02_geles.botoncito(2);
btn_03_geles.botoncito(3);
btn_04_geles.botoncito(3);

Por bryanisimo

664 de clabLevel



Genero:Masculino  

Geek

firefox

 

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