Programming the Game with JavaScript
As we mentioned in the previous section, Preparing the game timeline, stage, and library, since we are targeting the native web with an HTML5 Canvas document, we’ll be programming our game with JavaScript. Most code in Animate is bound directly to specific keyframes and is executed when the playhead reaches that frame.
As we start building the code for our game, recall that certain objects exist on the stage already and have been given instance names to allow us to manipulate them. In addition to this, there is a set of objects that only exist within the library and have been given Linkage IDs, which will allow us to create instances of these symbols and sound files at runtime.
The first step in our programming journey is to establish a set of global variables in our game. We’ll do this next since many other bits of code will rely on these variables.
Creating Global Variables
Document types that support JavaScript, including...