la creación de funciones de los botones en el bucle for?

  • BooGiE_MaN
  • Proficient
  • Proficient
  • Avatar de Usuario
  • Registrado: Jun 05, 2005
  • Mensajes: 387
  • Loc: Cape Town, South Africa
  • Status: Offline

Nota Octubre 4th, 2009, 2:03 am

Tengo una serie de botones en una película y quiero que cada uno de las mismas funciones que se les aplica a cabo sin necesidad de escribir código sin fin.

Traté
Código: [ Select ]
for(i=1;i<8;i++){
    var butname = "button"+i;
    butname.useHandCursor = false;
        butname.onRollOver = function(){
        showCursor();
        }
        butname.onRollOut = function(){
        hideCursor();
        }
}
  1. for(i=1;i<8;i++){
  2.     var butname = "button"+i;
  3.     butname.useHandCursor = false;
  4.         butname.onRollOver = function(){
  5.         showCursor();
  6.         }
  7.         butname.onRollOut = function(){
  8.         hideCursor();
  9.         }
  10. }

Im no seguro si ahora está buscando una instancia llamada "butname" y no "Button1", "button2", etc
¿Alguna idea?

Simply Links Directory
  • Anonymous
  • Bot
  • No Avatar
  • Registrado: 25 Feb 2008
  • Mensajes: ?
  • Loc: Ozzuland
  • Status: Online

Nota Octubre 4th, 2009, 2:03 am

  • BooGiE_MaN
  • Proficient
  • Proficient
  • Avatar de Usuario
  • Registrado: Jun 05, 2005
  • Mensajes: 387
  • Loc: Cape Town, South Africa
  • Status: Offline

Nota Octubre 4th, 2009, 2:23 am

encontrado la respuesta
Código: [ Select ]

for(var i=1;i<9;i++){
    
    var butname = "button"+i;
    trace(butname);
    _root[butname].useHandCursor = false;
        _root[butname].onRollOver = function(){
        showCursor();
        }
        _root[butname].onRollOut = function(){
        hideCursor();
        }
}
  1. for(var i=1;i<9;i++){
  2.     
  3.     var butname = "button"+i;
  4.     trace(butname);
  5.     _root[butname].useHandCursor = false;
  6.         _root[butname].onRollOver = function(){
  7.         showCursor();
  8.         }
  9.         _root[butname].onRollOut = function(){
  10.         hideCursor();
  11.         }
  12. }

Simply Links Directory
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • Avatar de Usuario
  • Registrado: May 28, 2003
  • Mensajes: 23403
  • Loc: Woodbridge VA
  • Status: Offline

Nota Octubre 4th, 2009, 6:19 am

Gracias por compartir la solución. Siempre es agradable encontrar la respuesta en su propio
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.

Publicar Información

  • Total de mensajes en este tema: 3 mensajes
  • Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 37 invitados
  • No puede abrir nuevos temas en este Foro
  • No puede responder a temas en este Foro
  • No puede editar sus mensajes en este Foro
  • No puede borrar sus mensajes en este Foro
  • No puede enviar adjuntos en este Foro
 
 

© 2011 Unmelted, LLC. Ozzu® es una marca registrada de Unmelted, LLC