function scanInput() { for(i = 1; i < 5 ;i++) { this['Hair' + i].btnIndex = i; this['Hair' + i].onRelease = function() { trace(this.name); // Getting Undefined here! } } } scanInput();