[AS3] TonyPa Tile-Tutorial (TileSheet Question)

Hello all,

I recently came up with an idea for a game. In the past i took a few Actionscript 3 courses, but my memory of those faded away quickly. I’m trying to get my knowledge up to speed but currently I’m just someone with basic know-how about programming, which might explain my question I suppose.

To create my game i need to use tilesets, and like others I’ve found TonyPa tutorials for this. He has been kind enough to allow us to look (and use) his sourcecode to learn how to make simple tile-based games and I’ve been trying that.
Tony’s homepage can be found here:

My problem is that even though i use TonyPas’ complete sourcecode I recieve an error-message, and in my current programings-state I’m not able to figure out how to fix that.

I’m getting:
1180: Call to a possibly undefined method TileSheet.

The code looks like this (the parts I belive might matter):



[SIZE=2][COLOR=#9900cc][SIZE=2][COLOR=#9900cc][SIZE=2][COLOR=#9900cc][SIZE=2][COLOR=#9900cc]package
[/COLOR][/SIZE][/COLOR][/SIZE][LEFT][SIZE=2][COLOR=#000000]{[/COLOR][/SIZE]
[LEFT][SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]import[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] flash.display.Bitmap;[/SIZE]
[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]import[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] flash.display.BitmapData;[/SIZE]
[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]import[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] flash.display.Sprite;[/SIZE]
[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]import[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] flash.geom.Point;[/SIZE]
[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]import[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] flash.geom.Rectangle;[/SIZE][/LEFT]
 
 
[LEFT]*[SIZE=2][COLOR=#009900][SIZE=2][COLOR=#009900]//class declaration[/COLOR][/SIZE][/COLOR][/SIZE]*[SIZE=2][COLOR=#009900]
[/COLOR][/SIZE][SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]public[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#9900cc][SIZE=2][COLOR=#9900cc]class[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] TBG02 [/SIZE][SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]extends[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Object {[/SIZE]
*[SIZE=2][COLOR=#009900][SIZE=2][COLOR=#009900]//declare variables[/COLOR][/SIZE][/COLOR][/SIZE]*[SIZE=2][COLOR=#009900]
[/COLOR][/SIZE][SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]private[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#6699cc][SIZE=2][COLOR=#6699cc]var[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] mapArr:Array;[/SIZE]
[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]private[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#6699cc][SIZE=2][COLOR=#6699cc]var[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] curMap:Array;[/SIZE]
[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]private[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#6699cc][SIZE=2][COLOR=#6699cc]var[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] complexTiles:Array;[/SIZE]
[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]private[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#6699cc][SIZE=2][COLOR=#6699cc]var[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] mapW:int;[/SIZE]
[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]private[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#6699cc][SIZE=2][COLOR=#6699cc]var[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] mapH:int;[/SIZE]
[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]private[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#6699cc][SIZE=2][COLOR=#6699cc]var[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ts:int;[/SIZE]
[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]private[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#6699cc][SIZE=2][COLOR=#6699cc]var[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] myParent:Sprite;[/SIZE]
[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]private[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#6699cc][SIZE=2][COLOR=#6699cc]var[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] tilesBmp:Bitmap;[/SIZE]
[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]private[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#6699cc][SIZE=2][COLOR=#6699cc]var[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] tSheet:BitmapData;[/SIZE][/LEFT]
 
 
[LEFT]*[SIZE=2][COLOR=#009900][SIZE=2][COLOR=#009900]//class constructor function[/COLOR][/SIZE][/COLOR][/SIZE]*[SIZE=2][COLOR=#009900]
[/COLOR][/SIZE][SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]public[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#339966][SIZE=2][COLOR=#339966]function[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] TBG02 (s:Sprite) {[/SIZE]
[SIZE=2]myParent = s;[/SIZE]
[SIZE=2]prepareGame ();[/SIZE]
[SIZE=2]}[/SIZE]
*[SIZE=2][COLOR=#009900][SIZE=2][COLOR=#009900]//start the game by preparing stuff[/COLOR][/SIZE][/COLOR][/SIZE]*[SIZE=2][COLOR=#009900]
[/COLOR][/SIZE][SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]private[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#339966][SIZE=2][COLOR=#339966]function[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] prepareGame ():[/SIZE][SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] {[/SIZE]
[SIZE=2]ts = 32;[/SIZE]
*[SIZE=2][COLOR=#009900][SIZE=2][COLOR=#009900]//we set new map data and call buildMap function[/COLOR][/SIZE][/COLOR][/SIZE]*[SIZE=2][COLOR=#009900]
[/COLOR][/SIZE][SIZE=2]mapArr = [[/SIZE]
[SIZE=2][ 0, 0, 0, 0, 0, 0, 0, 0],[/SIZE]
[SIZE=2][ 0,101,101,101,101,101,101, 0],[/SIZE]
[SIZE=2][ 0,101, 0,101,101,101,101, 0],[/SIZE]
[SIZE=2][ 0,101,101,101,101, 0,101, 0],[/SIZE]
[SIZE=2][ 0,101,101,101,101,101,102, 0],[/SIZE]
[SIZE=2][ 0, 0, 0, 0, 0, 0, 0, 0][/SIZE]
[SIZE=2]];[/SIZE]
[SIZE=2]complexTiles = [/SIZE][SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]new[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Array();[/SIZE]
[SIZE=2]complexTiles[102] = createComplexTile(1, [2]);[/SIZE]
*[SIZE=2][COLOR=#009900][SIZE=2][COLOR=#009900]//get the tilesheet[/COLOR][/SIZE][/COLOR][/SIZE]*[SIZE=2][COLOR=#009900]
[/COLOR][/SIZE][SIZE=2]**tSheet = **[/SIZE][SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]**new**[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]** TileSheet(0,0);**[/SIZE][/LEFT]


[LEFT]*[SIZE=2][COLOR=#009900][SIZE=2][COLOR=#009900]//set up current map array[/COLOR][/SIZE][/COLOR][/SIZE]*[SIZE=2][COLOR=#009900]
[/COLOR][/SIZE][SIZE=2]curMap = mapArr;[/SIZE]
*[SIZE=2][COLOR=#009900][SIZE=2][COLOR=#009900]//create map[/COLOR][/SIZE][/COLOR][/SIZE]*[SIZE=2][COLOR=#009900]
[/COLOR][/SIZE][SIZE=2]buildMap ();[/SIZE][/LEFT]
[SIZE=2]}[/SIZE]
[LEFT][SIZE=2]**[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]private[/LEFT]
[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE]**[LEFT]**[SIZE=2][COLOR=#339966][SIZE=2][COLOR=#339966]function[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2][COLOR=#000000] getImageFromSheet (s:Number):Bitmap {[/COLOR][/SIZE]
[LEFT]*[SIZE=2][COLOR=#009900][SIZE=2][COLOR=#009900]//number of columns in tilesheet[/COLOR][/SIZE][/COLOR][/SIZE]*[SIZE=2][COLOR=#009900]
[/COLOR][/SIZE]**[SIZE=2][COLOR=#6699cc][SIZE=2][COLOR=#6699cc]var[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2] sheetColumns:int = **tSheet.width / ts;**[/SIZE]
*[SIZE=2][COLOR=#009900][SIZE=2][COLOR=#009900]//position where to take graphics from[/COLOR][/SIZE][/COLOR][/SIZE]*[SIZE=2][COLOR=#009900]
[/COLOR][/SIZE]**[SIZE=2][COLOR=#6699cc][SIZE=2][COLOR=#6699cc]var[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2] col:int = s % sheetColumns;[/SIZE]
**[SIZE=2][COLOR=#6699cc][SIZE=2][COLOR=#6699cc]var[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2] row:int = Math.floor(s / sheetColumns);[/SIZE]
*[SIZE=2][COLOR=#009900][SIZE=2][COLOR=#009900]//rectangle that defines tile graphics[/COLOR][/SIZE][/COLOR][/SIZE]*[SIZE=2][COLOR=#009900]
[/COLOR][/SIZE]**[SIZE=2][COLOR=#6699cc][SIZE=2][COLOR=#6699cc]var[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2] rect:Rectangle = [/SIZE]**[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]new[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2] Rectangle(col * ts, row * ts, ts, ts);[/SIZE]
**[SIZE=2][COLOR=#6699cc][SIZE=2][COLOR=#6699cc]var[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2] pt:Point = [/SIZE]**[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]new[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2] Point(0, 0);[/SIZE]
*[SIZE=2][COLOR=#009900][SIZE=2][COLOR=#009900]//get the tile graphics from tilesheet[/COLOR][/SIZE][/COLOR][/SIZE]*[SIZE=2][COLOR=#009900]
[/COLOR][/SIZE]**[SIZE=2][COLOR=#6699cc][SIZE=2][COLOR=#6699cc]var[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2] bmp:Bitmap = [/SIZE]**[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]new[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2] Bitmap([/SIZE]**[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]new[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2] BitmapData(ts, ts, [/SIZE]**[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]true[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2], 0));[/SIZE]
[SIZE=2]bmp.bitmapData.copyPixels (tSheet, rect, pt, [/SIZE]**[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]null[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2], [/SIZE]**[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]null[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2], [/SIZE]**[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]true[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2]);[/SIZE]
**[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]return[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2] bmp;[/SIZE][/LEFT]
[SIZE=2]][/SIZE]
[/SIZE][/COLOR][/SIZE][/COLOR][/SIZE]

The place where i lock up complety is: tSheet = [SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]new[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] TileSheet(0,0);[/SIZE]

Imagine as you’d try to explain to your younger brother, because I haven’t been able to get past this and actually get to try out creating a map. I had a thought that it’s calling for the image (due to [COLOR=#0033ff]private[/COLOR][SIZE=2][COLOR=#6699cc][SIZE=2][COLOR=#6699cc]var[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] tSheet:BitmapData):wink: but in the zip-file with his sourcefiles there is nothing called ‘Tilesheet’ in it, no image or .as file. [/SIZE]

I have (while guessing) copied his example-tilsheet .gif-image, named that TileSheet etc to see if it was calling for that, but nay.

Could someone take a quick glimpse and give a helping hand to what might be the issue - is it refering to a function that I have not seen, that it can not find? I’m out of ideas, and can’t get past this first roadblock.

Thanks in advance for any help,
Walther.
[/LEFT]