Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help understanding this oop actionscript

Status
Not open for further replies.

iostream71

Programmer
Mar 13, 2002
229
US
I need help undestanding the bolded syntax.

1)I think the first part is creating an object "game" and assigned two variables default values.

2)I think in the second part a "Tile0" object is added to the "game" object.

3)I don't understand what the "game[]" syntax is doing. Is it making "game" into an array?

Hope this makes sense. This is used in flash mx:



game = (tileW:30,tileH:30);

game.Tile0 = function () {};
game.Tile0.prototype.walkable = true;
game.Tile0.prototype.frame = 1;


game.Tile1 = function () {};
game.Tile1.prototype.walkable = false;
game.Tile1.prototype.frame = 2;

function buildMap (map)
{
_root.attachMovie("empty", "tiles", ++d);
game.clip = _root.tiles;
var mapWidth = map[0].length;
var mapHeight = map.length;
for (var i = 0; i < mapHeight; ++i)
{
for (var j = 0; j < mapWidth; ++j)
{
var name = "t_" + i + "_" + j;
game[name] = new game["Tile" + map[j]];
game.clip.attachMovie("tile", name, i * 100 + j * 2);
game.clip[name]._x = (j * game.tileW);
game.clip[name]._y = (i * game.tileH);
game.clip[name].gotoAndStop(game[name].frame);
}
}
}
 
game" is a custom class. game[] is instantiating a game class object.

Wow JT that almost looked like you knew what you were doing!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top