# MovieClip Array Splicing Problem

**URL:** <https://forum.kirupa.com/t/movieclip-array-splicing-problem/297260>\
**Category:** flash\
**Created:** [September 28, 2009, 9:19pm UTC](https://forum.kirupa.com/t/movieclip-array-splicing-problem/297260 "2009-09-28T21:19:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pokenerd](https://avatars.discourse-cdn.com/v4/letter/p/e9bcb4/32.png) [@Pokenerd](https://forum.kirupa.com/u/Pokenerd)\
**Post date:** [September 28, 2009, 9:19pm UTC](https://forum.kirupa.com/t/movieclip-array-splicing-problem/297260/1 "2009-09-28T21:19:27Z")

</div>

Hello,  
For all you clever folks out there, I have a problem!

EDIT: I’m using CS4

I’m receiving this error:  
TypeError: Error #1010: A term is undefined and has no properties.  
at Main\_fla::function\_holder\_mc\_16/cleanList()  
at enemy1\_mc/killWPlode()  
at enemy1\_mc/update()

You can find my file at: [http://www.truploader.com/view/682740](http://www.truploader.com/view/682740)

Below is my function to clean my list. That part works - however for some reason I’m getting errors…

ActionScript Code:  
function cleanList():void {  
var lLength:int=MovieClip(root).enemyList.length;  
for (var i:int = 0; i\<lLength; i+=1) {  
if (! MovieClip(root).enemyList\*.alive) {  
MovieClip(root).enemyList.splice(i,1);  
}  
}  
}

The cleanList function is called here:

ActionScript Code:  
//passedText  
addEventListener(“enterFrame”,update);

var ySpeed:Number=3;  
var health:Number=1;  
var collideDamage:Number=8;  
var noPoint:Boolean=false;  
var arrayLocation:Number;  
var alive:Boolean;  
var cashValue:Number=50;  
cacheAsBitmap=true;

function update(e:Event):void {  
if (! MovieClip(root).isPaused) {  
this.y+=ySpeed;  
if (y\>stage.height) {  
this.kill();  
}

```
    if (health&lt;1) {
        killWPlode();
    }
}

```

}

function kill():void {  
removeEventListener(Event.ENTER\_FRAME, update);  
if (MovieClip(root).contains(this)) {  
MovieClip(root).removeChild(this);  
}  
alive=false;  
MovieClip(root).functions.cleanList();

}

function killWPlode():void {  
if (animation) {  
animation.play();  
}  
removeEventListener(Event.ENTER\_FRAME, update);  
if (! noPoint) {  
MovieClip(root).functions.writeText(this.x,this.y,cashValue);  
}  
alive=false;  
MovieClip(root).functions.cleanList();

}
