# Tile-based maps in AS3

I want to make a tile-based platformer in AS3.

I want my game to read an external maps file (in xml or json or somethimg similar) to draw a tile-based map.

I've seen loads of tutorials for this in AS2 and other languages, and the few I've found in AS3 are either incomplete or filled with extra unnecessary features. I just want to be able to draw a basic map from sprites in Flash.

Any links or information to point me in the right direction would be appreciated.

• As the answers show, questions like this just generate a list of responses without one being more correct than the others. I think it's not constructive and I'm voting to close. – MichaelHouse Jan 14 '13 at 20:04

A while ago I shared the AS3 code (+sample project) for a TMX parser on my blog: http://blog.pixelpracht.net/?p=59

TMX is the map format used by the Tiled Map Editor which imho is one of the best engine-independant editors for tile based maps.

FlashPunk supports that, you can even import a map made with Ogmo Editor.

This is a really powerful tool. The best side of this library, is that you don't have to waste weeks on it, it has only a few simple functions, it is highly optimized and as you can see huge projects use this library.

There's a great tutorial on as3isolib on gotoAndLearn: Part 1, Part 2.

Various Flash game frameworks have this sort of functionality built in. The gist:

2) Loop through the data in order to figure out where to place tiles.

2b) While looping through the data, instantiate the appropriate images and place them at the coordinates defined in the data.

Pseudocode:

var tileMap:Object = loadedJSON;
for each (var tileData:Object in tileMap) {
var tile:MovieClip = new MovieClip from tileData.clip;
tile.x = tileData.x;
tile.y = tileData.y;
}


(yes I know new MovieClip from tileData.clip isn't valid code. I said this is pseudocode; figure out how to instantiate MovieClips)