i want to make a 2D Array that is filled with random terrain and set the x,y and add it all at once if i can

is there a way to use what i have now and just tweek it to work if so can i be pointed the rite way to do that

or if this is just a mess i cnt use can someone point me in the way i should be going

package { import flash.display.*; import flash.events.*; public class TerrainSetUp extends MovieClip{ public var Snow : MovieClip = new MovieClip; public var Grass : MovieClip = new MovieClip; public var Sand : MovieClip = new MovieClip; public var Rocky : MovieClip = new MovieClip; public var Water : MovieClip = new MovieClip; public var RanNum : Number = 0; public var i : Number = 0; public var j : Number = 0; public var TerrainArray :Array = new Array(20 , 20); public var Set : Boolean = true; public function TerrainSetUp() { Snow = new SnowImg; Grass = new GrassImg; Sand = new SandImg; Rocky = new RockyImg; Water = new WaterImg; Snow.scaleX = 50; Grass.scaleX = 50; Sand.scaleX = 50; Rocky.scaleX = 50; Water.scaleX = 50; Snow.scaleY = 50; Grass.scaleY = 50; Sand.scaleY = 50; Rocky.scaleY = 50; Water.scaleY = 50; if(Set == true){ Set = false SetTheTerrain(); } } public function SetTheTerrain():void{ for( i = 0 ; i < 20 ; i ++){ RanNum = Math.floor(Math.random() * (5)) trace (i,j) if(RanNum == 0){ TerrainArray[i,j] = Grass; TerrainArray[i,j].x = (i * 50); TerrainArray[i,j].y = (j * 50); addChild(TerrainArray[i,j]); } if(RanNum == 1){ TerrainArray[i,j] = Snow; TerrainArray[i,j].x = (i * 50); TerrainArray[i,j].y = (j * 50); addChild(TerrainArray[i,j]); } if(RanNum == 2){ TerrainArray[i,j] = Rocky; TerrainArray[i,j].x = (i * 50); TerrainArray[i,j].y = (j * 50); addChild(TerrainArray[i,j]); } if(RanNum == 3){ TerrainArray[i,j] = Water; TerrainArray[i,j].x = (i * 50); TerrainArray[i,j].y = (j * 50); addChild(TerrainArray[i,j]); } if(RanNum == 4){ TerrainArray[i,j] = Sand; TerrainArray[i,j].x = (i * 50); TerrainArray[i,j].y = (j * 50); addChild(TerrainArray[i,j]); }else{ TerrainArray[i,j] = Grass; TerrainArray[i,j].x = (i * 50); TerrainArray[i,j].y = (j * 50); addChild(TerrainArray[i,j]); } if(i == 5){ i = 0 j++; if( j == 5){ break; } } } } } }