Placing the gems on stage may seem just a matter of adding some random DisplayObjects to Display List, but you'll see that we'll find ourselves in trouble very soon.
The idea: We are going to populate the array and physically place the jewels in the same script, so we'll fill the array with random integer numbers between 0 and 6, to represent each of the possible jewels. At the same time, we'll place a gem in the proper position and show the proper frame.
The development: You already know what we need to place the jewels as it's the same concept as placing cards, mines, crates, or whatever kind of asset in a tile-based game. Anyway, let's recap once again. We need:
a two-dimensional array to represent the game field
a DisplayObject to act as a container for all jewels
an instance of
gem_mc
object
A couple of for
loops will populate the array with random numbers, as gem_mc
objects will be placed on the stage.
Without closing bejeweled.fla
, create a new file and from New Document...