This is just the very basic idea, but it’s general enough to work as a platform for a wide range of games. Depending on the requirements you can add all sorts of things. Why is this method fast? The reason is that we don’t have any nested for loops. There are actually only 2 for.. in loops which are always performed each frame. When we enter a new area then we have 4 additional for.. in loops, but that happens far from every frame (unless the scrolling speed is very high). A simple data structure and pre-calculations also help, and by using local variables as much as possible. And I’m sure there is still room for improvement…
This method is not necessarily faster than a gotoAndStop engine, but it has many advantages in my opinion:
The tiles can have any size, in a gotoAndStop all tiles must be of the same size
It’s very easy to animate objects, like moving platforms
Relatively easy to add parallax effect on an object per object basis. In a gotoAndStop you would have to make a couple of “layers” and then scroll them with different speed.
You can place tiles in the same object on top of each other
Objects can be on top of each other. You can easily have 5 objects overlapping, and it will not be slower than if they were placed edge to edge.
It’s easy to make interactive objects, like swings (see the Flash MX Platform Demo at the end of the level)
What drawbacks are there?
If you want 100% of the screen covered in tiles at all times, this method could get a bit slower than a gotoAndStop unless you group the tiles very carefully.
It’s a bit more difficult to create a level editor. With a gotoAndStop engine, it’s very easy to create an editor to build maps. However, there is a nice way to actually build the levels in Flash using the tile set and then loop through the scene to create the map data.