Si possono generare più funzioni con un ciclo for?
Per generare sette funzioni che dovrebbero risiedere nella _root e che si dovrebbero chiamare
puls77()
puls76()
puls75()
puls74()
puls73()
puls72()
puls71()
... ho provato con un ciclo for.
Ma c'è qualcosa che non quadra.
Guardate un po':
Poi le richiamerei da rispettivi pulsanti.codice:for(i=7; i>0; i--) { // dichiaro le variabili: var puls7OK:String = "puls7" + String( i ); //eval( puls7OK ) var p7OK:String = "p7" + String( i ); //eval( p7OK ) var car7OK:String = "car7" + String( i ); //eval( car7OK ) // costruisco la funzione: function puls7OK() { // è qui che mi sa che non va! posy = _root.sottomenu.eval( p7OK )._y; newy = posy-vertic; _root.sottomenu.pareB2._y=newy; _root.sottomenu.pareB1._y=newy; newx2 = _root.sottomenu.eval( p7OK )._x - ((_root.sottomenu.eval( p7OK )._width / 2)+ abb2); _root.sottomenu.pareB2._x=newx2; newx1 = _root.sottomenu.eval( p7OK )._x + ((_root.sottomenu.eval( p7OK )._width / 2)+ abb1); _root.sottomenu.pareB1._x=newx1; loadMovie(_root.eval( car7OK ), _root.logoClip.carPag); } }
i centra sia nel nome della funzione che nel suo contenuto.
Grazie!