# Multiple Hit Test Way to Condence?

**URL:** <https://forum.kirupa.com/t/multiple-hit-test-way-to-condence/118676>\
**Category:** Uncategorized\
**Created:** [August 8, 2004, 2:19am UTC](https://forum.kirupa.com/t/multiple-hit-test-way-to-condence/118676 "2004-08-08T02:19:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brandon](https://avatars.discourse-cdn.com/v4/letter/b/f08c70/32.png) [@Brandon](https://forum.kirupa.com/u/Brandon)\
**Post date:** [August 8, 2004, 2:19am UTC](https://forum.kirupa.com/t/multiple-hit-test-way-to-condence/118676/1 "2004-08-08T02:19:15Z")

</div>

Is there a way to condence this. The t stands for tree and i have alot of them to hit test and i do not want to write out all the hit tests like below. Is there a way so it will accept any number after the T.

Heres the short version.  
if (this, hitTest(\_root.World.T1) or (this, hitTest(\_root.World.T2))) {  
EXT…

Thanks.

---

<div class="post-metadata">

**Author:** ![bobdoe](https://avatars.discourse-cdn.com/v4/letter/b/51bf81/32.png) [@bobdoe](https://forum.kirupa.com/u/bobdoe)\
**Post date:** [August 8, 2004, 2:37am UTC](https://forum.kirupa.com/t/multiple-hit-test-way-to-condence/118676/2 "2004-08-08T02:37:58Z")

</div>

yes there is, and its called an array. First you need to store all your instance names into an array and then apply the hitTest on the array through a loop. Ill try to outline the code for ya:  
tree\_amount = 25;  
trees = [];  
for(i=0;i\<tree\_amount;i++){  
trees\* = \_root.World[“T”+i]; //not sure if this is right,basically target your trees.  
}  
Then on the enterframe part:  
for(j=0;j\<\_root.tree\_amount;j++){  
if(this.hitTest(trees\*){  
trace(“tree was hit”);  
}  
}  
Remember this is just an outline of how I would code it, I hope you understand it.

---

<div class="post-metadata">

**Author:** ![Brandon](https://avatars.discourse-cdn.com/v4/letter/b/f08c70/32.png) [@Brandon](https://forum.kirupa.com/u/Brandon)\
**Post date:** [August 8, 2004, 2:55am UTC](https://forum.kirupa.com/t/multiple-hit-test-way-to-condence/118676/3 "2004-08-08T02:55:29Z")

</div>

why I feel so dumb thanks bobdoe
