# Changing arrays

**URL:** https://forum.kirupa.com/t/changing-arrays/252074
**Category:** Uncategorized
**Created:** [February 15, 2008, 4:29pm UTC](https://forum.kirupa.com/t/changing-arrays/252074 "2008-02-15T16:29:57Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![leonthelion](https://avatars.discourse-cdn.com/v4/letter/l/58956e/32.png) [@leonthelion](https://forum.kirupa.com/u/leonthelion)
#### Post date: [February 15, 2008, 4:29pm UTC](https://forum.kirupa.com/t/changing-arrays/252074/1 "2008-02-15T16:29:57Z")

</div>

Can you chage arrays that already exsist? Like I’m trying to get 1 guy to randomly attack 1 of 5 guys that are grouped together. I’m not sure if this code will work but I’m gonna try it anyway:

```php
 
var pick_enemy_5battle = new Array(0,1,2,3,4)

```

So that will make an array and using the type of thing Xin (if anyone remembers it) does:

```php
 
var attack_select = new Array(2,42,106,152);
gotoAndPlay(attack_select[random(4)]);

```

I would do something like  
\_global.enemyhp+pick\_enemy5battle-=attack  
So I have 2 questions,  
1.Would this code work correctly?

```php
 
var pick_enemy_5battle = new Array(0,1,2,3,4)
_global.enemyhp+pick_enemy5battle-=attack

```

2.How could I have something like (in the enemy mc)

```php
 
if(_global.enemy0hp<=1){this.removeMovieClip}

```

or something similar  
3.Would removing a movie clip inside a movieclip affect future movieclips or just that one?  
4.If an enemy died I wouldn’t want the guy attack a dead person, so how could I change the array to something like 0,1,3,4 instead of 0,1,2,3,4  
If anythings unclear just tell me and I’ll try to explain better. Thanks a lot =D
