# A Curious for-in Loop Problem

**URL:** https://forum.kirupa.com/t/a-curious-for-in-loop-problem/73541
**Category:** flash
**Created:** [December 17, 2004, 12:05pm UTC](https://forum.kirupa.com/t/a-curious-for-in-loop-problem/73541 "2004-12-17T12:05:27Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Brian\_S](https://avatars.discourse-cdn.com/v4/letter/b/c77e96/32.png) [@Brian\_S](https://forum.kirupa.com/u/Brian_S)
#### Post date: [December 17, 2004, 12:05pm UTC](https://forum.kirupa.com/t/a-curious-for-in-loop-problem/73541/1 "2004-12-17T12:05:27Z")

</div>

[font=Verdana, Helvetica, sans-serif][size=2]In preparation for adding an in-game menu to my Flash-based shooter-like game, [Black Cat Ops](http://www.gravitasgames.com/flash/black_cat_ops/), I decided to implement pause functionality. I added a method to my base enemy class that pauses the enemy by stopping its movement and animation and I added code to my game engine class that listens for and acts upon the input, halting attack effects and hit-testing and iterating through all of the members of the movie clip I am using to contain my enemies and pausing every member that is an instance of my enemy class (or, by obvious extension, a class that extends it).[/size][/font]

[font=Verdana, Helvetica, sans-serif][size=2]So here is the oddity: some enemies do not pause. And I do not mean that some types of enemies do not pause; I mean that some individual enemies do not pause even when others of the same class do. Were I using a standard variable-iterating for loop rather than a for-in loop, I would suspect that I had used an incorrect number or test sign somewhere, but that is not the case. It looks like the for-in loop is simply failing on some iterations, but they always seem to be the same ones on each level.[/size][/font]

[font=Verdana, Helvetica, sans-serif][size=2]Has anyone else experienced anything like this in ActionScript? If not, has anyone experienced any other oddities with for-in loops? Thank you in advance for any insights or other information. [/size][/font]
