# "For" Loop Problem

**URL:** <https://forum.kirupa.com/t/for-loop-problem/224173>\
**Category:** flash\
**Created:** [April 29, 2007, 3:20pm UTC](https://forum.kirupa.com/t/for-loop-problem/224173 "2007-04-29T15:20:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kingofnukes](https://avatars.discourse-cdn.com/v4/letter/k/9d8465/32.png) [@kingofnukes](https://forum.kirupa.com/u/kingofnukes)\
**Post date:** [April 29, 2007, 3:20pm UTC](https://forum.kirupa.com/t/for-loop-problem/224173/1 "2007-04-29T15:20:37Z")

</div>

ActionScript Code:  
[FONT=Courier New][LEFT][COLOR=#000000] **function** [/COLOR] hitCheck COLOR=#000000[/COLOR]  
[COLOR=#000000]{[/COLOR]  
[COLOR=#0000FF]for[/COLOR] [COLOR=#000000]([/COLOR][COLOR=#000000] **var** [/COLOR] i : [COLOR=#0000FF]Number[/COLOR] = [COLOR=#000080]0[/COLOR]; i \< enemies.[COLOR=#0000FF]length[/COLOR]; i ++[COLOR=#000000])[/COLOR]  
[COLOR=#000000]{[/COLOR]  
[COLOR=#0000FF]if[/COLOR] [COLOR=#000000]([/COLOR][COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]hitTest[/COLOR] [COLOR=#000000]([/COLOR]enemies [COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#000080]mc[/COLOR].[COLOR=#000080]attackPoint[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000])[/COLOR]  
[COLOR=#000000]{[/COLOR]  
attacked = [COLOR=#000000] **true** [/COLOR];  
[COLOR=#000000]}[/COLOR] [COLOR=#0000FF]else[/COLOR]  
[COLOR=#000000]{[/COLOR]  
attacked = [COLOR=#000000] **false** [/COLOR];  
[COLOR=#000000]}[/COLOR]  
[COLOR=#000000]}[/COLOR]  
[COLOR=#000000]}[/COLOR]  
[/LEFT]  
[/FONT]

When I call this function, it shows that its working when i trace it, but the hitTest only seems to work for enemies[0] any reason why?
