Espero que todos esten bien.
Les explico la duda que tengo. Resulta que tengo seis botones en el stage, llamados btn1, btn2, etc.
Además, en el primer frame escribí esto:
Código :
btn1.onRollOver = function() {
imgBtn1.gotoAndPlay("n1");
};
btn1.onRollOut = function() {
imgBtn1.gotoAndPlay("n3");
};
btn2.onRollOver = function() {
imgBtn2.gotoAndPlay("n1");
};
btn2.onRollOut = function() {
imgBtn2.gotoAndPlay("n3");
};
btn3.onRollOver = function() {
imgBtn3.gotoAndPlay("n1");
};
btn3.onRollOut = function() {
imgBtn3.gotoAndPlay("n3");
};
btn4.onRollOver = function() {
imgBtn4.gotoAndPlay("n1");
};
btn4.onRollOut = function() {
imgBtn4.gotoAndPlay("n3");
};
btn5.onRollOver = function() {
imgBtn5.gotoAndPlay("n1");
};
btn5.onRollOut = function() {
imgBtn5.gotoAndPlay("n3");
};
btn6.onRollOver = function() {
imgBtn6.gotoAndPlay("n1");
};
btn6.onRollOut = function() {
imgBtn6.gotoAndPlay("n3");
};
y funciona tal como quiero. Me pegunté si este código podía reducirlo a unas cuantas líneas y pensé que utilizando una función y un for. Esto es lo que escribí:
Código :
function onrollover_out() {
for (i=0; i<=6; i++) {
btn[i].onRollOver = function() {
imgBtn[i].gotoAndPlay("n1");
};
btn[i].onRollOut = function() {
imgBtn[i].gotoAndPlay("n3");
};
}
}
onrollover_out();
Pero no funciona y no sé porque.
No sé de programación y por lo tanto no sé si esto que hice en realida es posible que funcione.
Si alguien me da una pista de mi error se lo agradecería...
Muchos saludos.
