inserisci il codice in un prototipo e poi lo assegni dentro ad un ciclo, così
Codice PHP:
MovieClip.prototype.azione = function () {
this.onEnterFrame=function(){
if (_root.bottone_premuto == true) {
_root.campo_errore.text = ""
if (_root.ctrl_scala.cursore._x<=0){
_root.ctrl_scala.cursore._x=0
}
if (_root.ctrl_scala.cursore._x>=_root.ctrl_scala.barra._width){
_root.ctrl_scala.cursore._x=_root.ctrl_scala.barra._width
}
_root.fatt_scala(_root.ctrl_scala.cursore._x)
_root.rdm_cursore()
if (_root.cont.prova1.text == "seconda voce") {
ctrl_scala.cursore._x=20;
map._y = 113;
map._x = -50;
} else if (_root.cont.prova1.text == "terza voce") {
ctrl_scala.cursore._x=20;
map._y = 50;
map._x = -20;
} else {
_root.campo_errore.text = "elemento non trovato"
}
}
}
}
for (var i=1; i<=100; i++) {
var bt = _root["bottone"+i];
bt.onPress = function (){
this.azione()
};
bt.onRelease = function () {
delete this.onEnterFrame;
}
}