We said we are going to pick tiles with a mouse click. To manage mouse events such as clicks, movements, and rollovers, AS3 provides a dedicated class called
MouseEvent. The first thing we need to do is to import this new class.
Import it before main class declaration, in the code delimited by
// importing classes just like you imported
// importing classes import flash.display.Sprite; import flash.events.MouseEvent; // end of importing classes
MouseEvent class is contained in the
flash.events package, that's why I had to import another package.
Now you are ready to handle mouse events. Modify the tile placing loop (the code between
// tile placing loop and
// end of tile placing loop) this way:
// tile placing loop ...