# Refer to all enemies in array

**URL:** https://forum.kirupa.com/t/refer-to-all-enemies-in-array/331855
**Category:** flash
**Created:** [November 8, 2013, 2:53pm UTC](https://forum.kirupa.com/t/refer-to-all-enemies-in-array/331855 "2013-11-08T14:53:47Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![BindleStick](https://avatars.discourse-cdn.com/v4/letter/b/8491ac/32.png) [@BindleStick](https://forum.kirupa.com/u/BindleStick)
#### Post date: [November 8, 2013, 2:53pm UTC](https://forum.kirupa.com/t/refer-to-all-enemies-in-array/331855/1 "2013-11-08T14:53:47Z")

</div>

I’m having trouble referring to all enemies in array. Maybe I’m over thinking it, but I’m stumped. I create a for loop to create 8 enemies, then push them in an array. I want to refer to all of them instead in order to check if all individual enemies are hitting something. I could do them individually, but it would only work for one enemy in the array instead of all.

```auto
public var enemy:Enemy;
public var enemyArray:Array = [];
private var onGameTimer:Timer = new Timer(1000);// For checking the Game
private var onLevelTimer:Timer = new Timer(500, 1);//For checking the Level
public function Main()
{

onGameTimer.addEventListener(TimerEvent.TIMER, timerGame);
onLevelTimer.addEventListener(TimerEvent.TIMER, timerLevel);
onLevelTimer.start();
}
function timerLevel(event:TimerEvent)
{
var i:int;
for (i = 0; i < 8; i++)
{
enemy = new Enemy();
enemyArray.push(enemy);
}

function timerGame(event:TimerEvent)
{
trace(enemyArray[0], enemyArray*);
}

```

I trace enemyArray[0] - [8] and it seems to work fine, but enemyArray\* comes up as undefined.
