ABSTRACT

After the first blistering introduction to ActionScript in Chapter 1, we now take a more leisurely stroll through the basics of programming, starting with variables. The most fundamental aspect of programming is the ability to store and retrieve data. In essence, all computer programming involves the manipulation of data. If your game uses a moving animated character running, jumping and shooting, you will need to store the position, size and action of the character as the game develops; this information is not static, it varies as the user plays the game. In this chapter we will look at how a variable can be used to store lots of different types of information, including the data you would need for your character. We will look at how to set a variable’s value and how to get the value stored in a variable. We will look at using chunks of variables in a structure called an Array. Along the way we will examine the options using animated sprites. We will let the user input a code that controls the behaviour of the sprite. Finally, we will let the user replay an animation using information stored in the string variable.