Comunidad de diseño web y desarrollo en internet online

Recorrer acciones de muchos botones con un for

Citar            
MensajeEscrito el 07 Abr 2008 06:51 pm
Hola, tengo en el stage un monton de clip que uso como botones..llamados p1..p2..p3 ....y cada uno con una acción similar gotoAndPlay("ficha1") para el boton p1....gotoAndPlay("ficha2") para el boton p2....
el caso es que quiero reducir código pues son 20 botones....
He probado con:
for (i=0; i<21; i++){
p+i.onRelease=function(){
gotoAndPlay("ficha"+i);
}

pero no me sale...

help, please!

Por outsider

74 de clabLevel



 

Madrid

firefox
Citar            
MensajeEscrito el 07 Abr 2008 09:34 pm

Código :

var theRoot:MovieClip = this;
for (var i:Number = 1; i <= 20; i++){
theRoot["p" + i].frameToGo = "ficha" + i;
theRoot["p" + i].onRelease=function(){
     gotoAndPlay(this.frameToGo);
}

Por The Fricky!

Presidente

6168 de clabLevel

3 tutoriales
8 articulos

Genero:Masculino   Bastard Operators From Hell Héroes

Piccola Venezia...

firefox
Citar            
MensajeEscrito el 08 Abr 2008 08:38 am
...pero me sigue sin funcionar...los clips que actuan como botones estan dentro de otro clip, tengo este código:

Código :

var theRoot.clipgene:MovieClip = this;
for (var i:Number = 1; i <= 20; i++){
theRoot.clipgene["p" + i].frametoGo= "p" + i;
theRoot.clipgene["p" + i].onRelease=function(){
     gotoAndPlay(frametoGo);
}
}

Por outsider

74 de clabLevel



 

Madrid

firefox
Citar            
MensajeEscrito el 08 Abr 2008 09:17 am
ya me funciona!!...un error mio:

Código :

var theRoot:MovieClip = this;
for (var i:Number = 1; i <= 20; i++){
clipgene["p" + i].frameToGo = "ficha" + i;
theRoot.clipgene["p" + i].onRelease=function(){
      gotoAndPlay(frametoGo);
}
}


Mil Gracias!!

Por outsider

74 de clabLevel



 

Madrid

firefox

 

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