# Simple - for each question

**URL:** https://forum.kirupa.com/t/simple-for-each-question/233387
**Category:** Uncategorized
**Created:** [July 23, 2007, 4:46pm UTC](https://forum.kirupa.com/t/simple-for-each-question/233387 "2007-07-23T16:46:38Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![tezzutezzu](https://avatars.discourse-cdn.com/v4/letter/t/df705f/32.png) [@tezzutezzu](https://forum.kirupa.com/u/tezzutezzu)
#### Post date: [July 23, 2007, 4:46pm UTC](https://forum.kirupa.com/t/simple-for-each-question/233387/1 "2007-07-23T16:46:38Z")

</div>

Hello there!  
Here’s a very simple question about a practical issue i have:

if I use the for each method to lookup into an array,  
how could I know the index number of the current element WITHOUT using a counter?  
With a simple for loop I’d use the increasing var but with a for each?  
Here is a practical example, let’s say I want to put all of my sprites one next to each other but i don’t want to use a counter:

```auto

for each (var i:Sprite in myArray) {
trace(i) //returns the Sprite
i.x = 100* counter? 
}

```

In the end I wonder if there’s a quick way to return the index of the current looped element. In the Array documentation I couldn’t find anything speaking about this.  
I think counters are quite sad to use sometimes (feel like in grammar school).

thanks!
