# Splice - whats wrong with this

**URL:** <https://forum.kirupa.com/t/splice-whats-wrong-with-this/256659>\
**Category:** Uncategorized\
**Created:** [April 5, 2008, 10:24am UTC](https://forum.kirupa.com/t/splice-whats-wrong-with-this/256659 "2008-04-05T10:24:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nameez](https://avatars.discourse-cdn.com/v4/letter/n/2acd7d/32.png) [@nameez](https://forum.kirupa.com/u/nameez)\
**Post date:** [April 5, 2008, 10:24am UTC](https://forum.kirupa.com/t/splice-whats-wrong-with-this/256659/1 "2008-04-05T10:24:10Z")

</div>

i have a problem deleting movieclips attached to a empty MC and pushed into an array in the empty mc.

im using splice method.it seems doesnt when deleting mc’s randomly.

here’s the code and fla attached.

```auto
function starter(){
selectedView = _root.attachMovie("McDesign_mc","designer",this.getNextHighestDepth());
}
starter()
function attachDesignElement():Void {
	nameIndex = selectedView.elements.length //element array defined inside designer
	clipHolder = selectedView.attachMovie("clipart","clipart"+nameIndex,selectedView.getNextHighestDepth())
	clipHolder.onRelease = function(){
		element = substring(this, 25, -1)
		selectedView.elements[element].removeMovieClip()
		selectedView.elements.splice(element,1)
		trace(selectedView.elements)
	}
	selectedView["clipart"+nameIndex].test.text = nameIndex; 
	selectedView["clipart"+nameIndex]._x = selectedView["clipart"+nameIndex]._y = nameIndex*15+40;
	selectedView.elements.push(clipHolder);
}
_btn.onRelease = function() {
	attachDesignElement()
}

```

if you delete 3rd mc and try deleteing a greater one (ex 5) it doesnt work.  
please help
