# Splice() method problem

**URL:** <https://forum.kirupa.com/t/splice-method-problem/276515>\
**Category:** Uncategorized\
**Created:** [November 30, 2008, 12:33am UTC](https://forum.kirupa.com/t/splice-method-problem/276515 "2008-11-30T00:33:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Didi32](https://avatars.discourse-cdn.com/v4/letter/d/eb8c5e/32.png) [@Didi32](https://forum.kirupa.com/u/Didi32)\
**Post date:** [November 30, 2008, 12:33am UTC](https://forum.kirupa.com/t/splice-method-problem/276515/1 "2008-11-30T00:33:23Z")

</div>

Hi,

I’m making a little card game and load cards as sprite inside of an array. I add these array to the stage (addChild). What I would like to do is that when one card goes on a certain area, it is deleted from the array. I have figured out everything except how to delete only one element from the array while keeping the rest.

Here are the two problematic chunks of code:

```auto
private function loadDeck(evt:LoadedDeck):void {
            theArray = evt.deckLoad;

            for (var i:int = 0 ; i < theArray.length; i++) {
                
                cardDeck* = new SingleCard(theArray*);
                deckContainer.addChild(cardDeck*);
            }
            
        }

```

Above creates an instance of the SingleCard class for each cardDeck.

```auto

for (var i:int = 0; i < cardDeck.length; i++){
            
            if (cardDeck* == e.target){

                
                var numDel:Number = i;
            }
  }            
trace("deleting card " + numDel + ", card deck was " + cardDeck.length);

[COLOR=Red]cardDeck.splice(numDel,numDel);[/COLOR]

 trace("card deck is now " + cardDeck.length);

```

This chunk of code has unexpected results, I just tried to delete cardDeck[10] only and here is what is traced:  
deleting card 10, card deck was 50  
card deck is now 40

What I would expect is the card deck to now be 49… not just 40.

Thanks for your help,

Didi
