# Array Hittest

**URL:** <https://forum.kirupa.com/t/array-hittest/287374>\
**Category:** flash\
**Created:** [April 30, 2009, 12:56am UTC](https://forum.kirupa.com/t/array-hittest/287374 "2009-04-30T00:56:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mavoric](https://avatars.discourse-cdn.com/v4/letter/m/ecb155/32.png) [@mavoric](https://forum.kirupa.com/u/mavoric)\
**Post date:** [April 30, 2009, 12:56am UTC](https://forum.kirupa.com/t/array-hittest/287374/1 "2009-04-30T00:56:27Z")

</div>

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…

```auto
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.

```auto

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

```
