for (var i=0; i<= 3; i++) { _root["button"+i]._id = i _root["button"+i].onPress = function (){ trace (this._id) } }