ABSTRACT

In languages like C, a main loop is literally a coded loop (like a while or for loop) that runs until a condition is met. In some cases, this is also referred to as the state machine , because it is the logic that determines which “ state ” the game is in — pregame, in-game, post-game, etc. — and performs the corresponding functions. In ActionScript, it must be set up differently because a regular loop would lock up the Flash player waiting for the game to fi nish. Because of its animation heritage, Flash works in the context of frames, much like a movie. It has a frame rate, or number of frames per second, that can be defi ned. When a frame passes, Flash updates the screen, making it the perfect time to perform logic. This can seem odd to developers used to other languages, but it quickly becomes second nature. I’ll discuss game loops further later, as they will be the driving force behind our game code.