Array Hittest

I need to do a hittest on a lot of objects, so as not to crash the users computer I’ve decided to only run hittests on objects with 100pixels of the screen. They are listed in an array as follows…

onscreen_objects[0] = box1;
onscreen_objects[1] = box2;

Then I need to loop and hittest them all. However its not working, if I change the array element to the instance name it works fine. So any help with what im doing wrong is greatly appreciated.


        for(z=0; z<onscreen_objects.length; z++)
        {
            if (_root.onscreen_objects[z].hitTest(spot_x, spot_y, true)) {
                trace('hit');
            }
        }