How to remove an element in an 2-d array

Hi,

I’m trying to create a tile-based game, and I’m running into difficulty with it. I hope you can help.

Using a for-loop I made a grid of movieclips. But I wanted it so every second row had one less than the one above it. I thought I had that sorted when I placed an if statement in the method. However, flash still “sees” the missing movieclip. I’ve tried to splice the array element from it, but instead of removing it, it seems to have copied it.

Here’s the code:


package 
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import flash.events.Event;

	public class Distance extends MovieClip
	{
		public var hexagon_container:MovieClip = new MovieClip();

		var hexWidth:Number = 85.0;
		var hexHeight:Number = 98.0;
		var gridX:int = 4;
		var gridY:int = 9;
		var hexNum:int = 0;

		public function Distance():void
		{
			var fieldArray:Array = new Array();
			var hexCard:HexCard = new HexCard  ;

			function layField():void
			{
				addChild(hexagon_container);
				hexagon_container.x = 230;		
				hexagon_container.y = 20;
				var hexagonXPos:Number;
				var hexagonYPos:Number;
				var y_pos:int;
				var x_pos:int;
				
				for (y_pos =0; y_pos<gridY; y_pos++)
				{
					fieldArray.push(new Array());
					for (x_pos=0; x_pos<gridX; x_pos++)
					{
						hexagonXPos = (hexWidth*x_pos+(y_pos%2)*hexWidth/2);
						hexagonYPos = (hexHeight * y_pos * 0.75) ;
						var hexagon:HexField = new HexField();
						
						hexagon_container.addChild(hexagon);	
											
						hexagon.x = hexagonXPos;
						hexagon.y = hexagonYPos;
						fieldArray[y_pos].push(hexagon);
						
						if (y_pos % 2 == 1 && x_pos == gridX - 1)
						{							
							hexagon_container.removeChild(hexagon);
							fieldArray[y_pos].splice(3, 1);
						}
						
						trace (fieldArray[y_pos].length + ","); 

//Output:1,2,3,4,1,2,3,3,1,2,3,4,1,2,3,3,1,2,3,4,1,2,3,3,1,2,3,4,1,2,3,3,1,2,3,4,
					}
				}
				
			}// end of layField function
			layField();


Where am I going wrong here? I think the output should be: 1,2,3,4,1,2,3,1,2,3,4,1,2,3,1,2,3,4… etc.

Any help would be greatly appreciated.