TypeError: Error #1010 (solved)

1 post

Flag Post

Nevermind, solved. I had to edit the mapRowCount and mapColumnCount to match my map.

Having problems figuring out what I need to fix here. Here is the error message, seems kind of non specific:

TypeError: Error #1010: A term is undefined and has no properties.
at classes::ZombieDemo/drawLevelBackGround()
at classes::ZombieDemo()

Update: searching with adobe help, I now tested with “permit debugging”. It appears the error is line 90? Which in the code is.

blitTile = levelTileMap[rowCtr][colCtr];

And here’s the code

I was wondering if it has something to do with my tilesheet. have the png “BuildingSheet” imported into my library, but I copied the code from the book I’m using, and did whatever they did with their png.

package classes
	import flash.display.Sprite;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.geom.Rectangle;
	import flash.geom.Point;
	import classes.TileSheet;
	public class ZombieDemo extends Sprite
		public static const TILE_BUILDING:int = 0;
		public static const TILE_LANDSCAPE:int = 1;
		private var buildingFrames:Array;
		private var landscapeFrames:Array;
		private var tileSheetData:Array;
		private var tileWidth:int = 32;
		private var tileHeight:int = 32;
		private var mapRowCount:int = 15;
		private var mapColumnCount:int = 20;
		private var level:int = 1;
		private var levelTileMap:Array;
		private var levelData:Level;
		private var levels:Array = [undefined,new Level1()];
		private var canvasBitmapData:BitmapData=new BitmapData(tileWidth * mapColumnCount, tileHeight * mapRowCount, true, 0x00000000);
		private var canvasBitmap:Bitmap = new Bitmap(canvasBitmapData);
		private var blitPoint:Point = new Point();
		private var tileBlitRectangle:Rectangle = new Rectangle(0, 0, tileWidth, tileHeight);
		private var tileSheet:TileSheet = new TileSheet(new BuildingSheet(0,0), tileWidth, tileHeight);
		public function ZombieDemo() 
			trace("tileSheetData.length=" + tileSheetData.length);
			trace("buildingFrames.length=" + buildingFrames.length);
			trace("landscapeFrames.length=" + landscapeFrames.length);


private function readBackGroundData():void {
			levelTileMap = [];
			levelData = levels[level];
			levelTileMap = levelData.backGroundMap;

private function drawLevelBackGround():void {
			var blitTile:int;
			for (var rowCtr:int=0;rowCtr<mapRowCount;rowCtr++) {
				for (var colCtr:int = 0; colCtr < mapColumnCount; colCtr++) {
					blitTile = levelTileMap[rowCtr][colCtr];
					tileBlitRectangle.x = int(blitTile % tileSheet.tilesPerRow) * tileWidth;
					tileBlitRectangle.y = int(blitTile / tileSheet.tilesPerRow) * tileHeight;
					blitPoint.y = rowCtr * tileWidth;
					canvasBitmapData.copyPixels(tileSheet.sourceBitmapData,tileBlitRectangle, blitPoint);

Another update: I traced (array.join());
for levelTileMap = levelData.backGroundMap;

And it appears it was filled correctly. So I guess the problem has to do with the BuildingSheet tilesheet png, or the drawLevelBackGround function…

Update, the complete loop seems to be going through, up to x= 608 y = 288. So something happens when it is on the 10th row… my map is only 10 × 10 tiles (each 32×32 pixels). While the original was 20×15 tiles. Hence there is an error because of the differing map size here.