Adding the balance

Let's prepare the gamefield and initialize the game array. We will place the fulcrum in the bottom of the gamefield, horizontally centered, and the balance over the fulcrum. Then we'll create a 6x8 array filled with zeros.

Without closing ballbalance.fla, create a new file and from New Document window select ActionScript 3.0 Class. Save this file as Main.as in the same path you saved ballbalance.fla. This is the content of Main.as:

package { import flash.display.Sprite; import flash.events.Event; import flash.events.MouseEvent; public class Main extends Sprite { private var balance:balance_mc=new balance_mc(); private var gameArray:Array; public function Main() { prepareArray(); buildBalance(); } private function buildBalance():void ...

Get Flash Game Development by Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.