# AS2: Array Slice and Pop

**URL:** https://forum.kirupa.com/t/as2-array-slice-and-pop/290449
**Category:** flash
**Created:** [June 15, 2009, 8:49am UTC](https://forum.kirupa.com/t/as2-array-slice-and-pop/290449 "2009-06-15T08:49:32Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![lilleypants](https://avatars.discourse-cdn.com/v4/letter/l/f17d59/32.png) [@lilleypants](https://forum.kirupa.com/u/lilleypants)
#### Post date: [June 15, 2009, 8:49am UTC](https://forum.kirupa.com/t/as2-array-slice-and-pop/290449/1 "2009-06-15T08:49:32Z")

</div>

Hello,

I am using the following code to make an array of 3 values and each time a button is clicked it adds a number to a certain location in the array - so the value one goes into slot 0 and so on…

```auto

_global.slotArray = Array("", "", "");

add_mc.onRelease = function(){
	_global.slotArray.splice(0,0,"1");
	_global.slotArray.pop();
	trace(_global.slotArray);
}

add2_mc.onRelease = function(){
	_global.slotArray.splice(1,0,"2");
	_global.slotArray.pop();
	trace(_global.slotArray);
}

add3_mc.onRelease = function(){
	_global.slotArray.splice(2,0,"3");
	_global.slotArray.pop();
	trace(_global.slotArray);
}

```

If I click the buttons in order of add, add2 and add3 then the array looks fine like so: 1,2,3 however if I click them out of order it produces the following result: 1,2 and 3 goes missing - it seems to be popping out values.

Anyone know why this is?

Any help would be great thanks
