Dynamic variable reference

I have some variables called
_root.name1
_root.name2
_root.name3
_root.name4

I want to initiate the three variables by refering to them dynamically.
Here is my script, which is not working (The variables never get any value):

for (var i = 0; i<7; i++) {
     if (i%2 == 0) {
          var temp = "name"+((i+2)/2);
          _root[temp] = my_array*;
     }
}

How do I refer to the variables dynamically?