stop();
//loadTileBitmapData
var sourceTiles:tileMapBitmap=new tileMapBitmap(1,1);
//renderMap Variable Definitions
var rowCtr:Number=0;
var colCtr:Number=0;
var mapRows:Number=7;
var mapCols:Number=9;
var tileNum:int=0;
var destY:int=0;
var destX:int=0;
var sourceX:int=0;
var sourceY:int=0;
var sourceRect:Rectangle=null;
var destPoint:Point=null;
var screenBitmapData=new BitmapData((44*9)+1,(44*7)+1,false,0x000000);
var displayData=new Bitmap(screenBitmapData);
stage.addChild(displayData);
displayData.x=5;
displayData.y=5;
/************
* Tile Maps *
************/
var tileMap1:Array = new Array();
tileMap1.push(new Array(0,0,0,0,9,253,0,0,0));
tileMap1.push(new Array(0,0,0,0,19,0,0,0,0));
tileMap1.push(new Array(0,32,0,0,19,32,0,0,0));
tileMap1.push(new Array(0,0,0,0,19,0,0,0,0));
tileMap1.push(new Array(0,0,0,32,19,0,0,32,0));
tileMap1.push(new Array(0,0,0,0,19,0,0,0,0));
tileMap1.push(new Array(161,161,161,161,162,161,161,161,161));
var colMap1:Array = new Array();
colMap1.push(new Array(0,0,0,0,0,0,0,0,0));
colMap1.push(new Array(0,0,0,0,0,0,0,0,0));
colMap1.push(new Array(0,0,0,0,0,0,0,0,0));
colMap1.push(new Array(0,0,0,0,0,0,0,0,0));
colMap1.push(new Array(0,0,0,0,0,0,0,0,0));
colMap1.push(new Array(0,0,0,0,0,0,0,0,0));
colMap1.push(new Array(0,0,0,0,0,0,0,0,0));
function renderMap(tileArray) {
stage.removeChild(displayData);
//using the data in the array add to screenBitmapData
screenBitmapData=new BitmapData((44*9)+1,(44*7)+1,false,0x000000);
//screenBitmapData.copyPixels(tilesBitmapData,new Rectangle(0,0,32,32), new Point(0,0));
for (rowCtr=0; rowCtr<mapRows; rowCtr++) {
for (colCtr=0; colCtr<mapCols; colCtr++) {
tileNum=int(tileArray[rowCtr][colCtr]);
destY=rowCtr*44;
destX=colCtr*44;
sourceX=(tileNum % 10)*44;
sourceY=(Math.floor(tileNum/10))*44;
sourceRect=new Rectangle(sourceX,sourceY,45,45);
destPoint=new Point(destX,destY);
screenBitmapData.copyPixels(sourceTiles,sourceRect,destPoint);
}
}
displayData=new Bitmap(screenBitmapData);
stage.addChild(displayData);
displayData.x=5;
displayData.y=5;
}
renderMap(tileMap1);