for (i = 1;i < 36;i++) { var btn = this['btn'+i]; btn.onPress = function() { trace(this); } } delete btn;