for (i=0; i<4; i++) { for (x=0; x<4; x++) { Button.prototype.nextF = function() { this.onRelease = function() { anim+i.nextFrame(); }; }; Button.prototype.prevF = function() { this.onRelease = function() { anim+i.prevFrame(); }; }; Button.prototype.play = function() { this.onRelease = function() { anim+i.play(); }; }; Button.prototype.stop = function() { this.onRelease = function() { anim+i.stop(); }; }; but+i+x.nextF(); but+i+(x+1).prevF(); but+i+(x+2).play(); but+i+(x+3).stop(); } }