6 Replies Latest reply on Aug 31, 2009 6:55 AM by MarionMacDonald

    array.length doesn't alter after element removed?


      In frame 1, I have loaded 9 movie clips (pieces of a graphic) and their instance names (piece1, piece2 etc) are in an array, arrPieces.   In frame 3, I am trying to remove them but I discovered I had a problem with my while loop.   I removed the loop and discovered the problem is really that the array size doesn't reduce after I delete an element.   I haven't been able to find this in the documentation.  Is this true?  I suspect not.


      This is what I've stripped the code in frame 3 down to:


      trace(arrPieces.length);     // 9 as expected
      var whichPiece=Math.floor(Math.random() * 9) + 1;
      trace(whichPiece);   // as expected
      trace(arrPieces);   // as expected
      trace(arrPieces.length);   // still gives 9 - not expected



      Something obvious, I suppose, but I can't see it.   Help appreciated.