Help on basic variable

sorry i only know AS2, and was not doing actionscript for a while. i can’t pass the variable to the object, please check what’s wrong with my script. i want to put a variable after the obj. so when it randomize, it pass the random number after the obj.
Thanks in advance

obj1._visible = false;
obj2._visible = false;
function reveal() {
var randomNumber = random(2)+1;
obj[randomNumber]._visible = true;
}