Be a Supporter!

Tile games, and undefined variables

  • 228 Views
  • 3 Replies
New Topic Respond to this Topic
creepernaut
creepernaut
  • Member since: Dec. 12, 2012
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Tile games, and undefined variables 2012-12-14 13:35:44 Reply

I'm new to actionscript, and I'm making a game with tiles in AS3. I've been using a tutorial I found here on Newgrounds, but I'm having a problem. I've followed the tutorial, it's from the 08 tutorial collab, but each time I try to test the game I get a ton of undefined property errors and an undefined method error. Apparently properties d, game,tiles, c, and r are undefined properties, and createEmptyMovieClip is an undefined method. Here is all of my code, it's all from the first and only frame.

map1 = [[0,0,0,0,0,0,0,0,0,0],
[0,1,1,1,0,0,0,0,0,0],
[0,1,0,0,0,0,0,0,0,0],
[0,1,1,1,0,0,0,0,0,0],
[0,0,0,1,0,0,1,1,0,0],
[0,1,1,1,0,0,1,0,1,0],
[0,0,0,0,0,0,1,0,1,0],
[0,0,0,0,0,0,1,0,1,0],
[0,0,0,0,0,0,1,1,0,0],
[0,0,0,0,0,0,0,0,0,0]];
game = {tileW:30,tileH:30};
d = 0;
game.tile0 = function() {};
game.tile0.prototype.frame = 1;
game.tile0 = function() {};
game.tile0.prototype.frame = 2
function buildMap(map){
createEmptyMovieClip("tiles",++d);
game.clip = tiles;
for(r = 0;r < map.length;++r){
for(c = 0;c < map[0].length;++c){
name = "tile_"+r+"_"+c;
game[name] = new game["tile"+map[r][c]];
game.clip.attachMovie("tile",name,++d);
game.clip[name]._x = game.tileW * c;
game.clip[name]._y = game.tileH * r;
game.clip[name].gotoAndStop(game[name].frame);
};
};
};
buildMap(map1);
ProfessorFlash
ProfessorFlash
  • Member since: Oct. 6, 2007
  • Offline.
Forum Stats
Member
Level 32
Programmer
Response to Tile games, and undefined variables 2012-12-14 13:48:00 Reply

At 12/14/12 01:35 PM, creepernaut wrote: I'm new to actionscript, and I'm making a game with tiles in AS3.

The code you are using is AS2.


You can solve pretty much any problem you may have with AS3 by consulting the AS3 Language reference.

Spysociety
Spysociety
  • Member since: Dec. 30, 2009
  • Offline.
Forum Stats
Member
Level 21
Blank Slate
Response to Tile games, and undefined variables 2012-12-14 13:49:08 Reply

That's because the code is in AS2.

MSGhero
MSGhero
  • Member since: Dec. 15, 2010
  • Offline.
Forum Stats
Supporter
Level 16
Game Developer
Response to Tile games, and undefined variables 2012-12-14 14:27:24 Reply

Start here. I wrote a tutorial on tile-based mechanics, but you should start with basic AS3 first.