|[ LiB ]|
To ease you in, I'll first describe what a computer program actually is. Simply put, a computer program is a file that contains a list of instructions for the computer to follow. Now that I've thrown that general statement at you, let's talk about generic system architecture. This will help you better understand the concepts that will be explored throughout this book.
When you click on a button, or select an option from a menu, or give your computer any other task to carry out, your computer fetches the instructions from its RAM. RAM stands for Random Access Memory . This is where all the running (and sometimes dormant ) programs are stored while the computer is on. RAM is also the place where your scripts will be interpreted and where the computer will fetch the code.
Once the computer finds the instructions for carrying out the task you've ordered, the CPU executes the task. The CPU, or Central Processing Unit , is the brain of the computer.
Hertz is a measure of cycles per sec ond. Computers nowadays are mea sured in gigahertz, which clock in at a billion cycles per second. Older computers are measured in mega hertz, which clock in at a million cycles per second.
The speed at which the CPU can fetch instructions is measured in cycles per second, or hertz. Check out Figure 2.1 for an easy-to-swallow visual.
As you get more experienced , you will learn how to optimize your code so that your program can run much faster overall. But there's no need to get ahead of ourselves . As I said before, a computer program is simply a file that contains a list of instructions for the computer to follow.
What instructions does the computer understand? A computer language is nothing like a spoken language. It's more like an instruction set that can and should be written out in a certain way. This certain way is referred to as the language's syntax . The computer will complain if it doesn't understand the instruction that you give itif you don't use the correct syntax.
A few examples of computer languages include C, C++, BASIC, Assembly Language, and ActionScript. These languages are all different, but once you understand the fundamental programming concepts behind them, it won't be difficult to understand them all. Most of the learning curve comes while learning your first computer language. Our language in this book, of course, is ActionScript.
Computer languages were designed to be understood by humans, not by machines. In order for the machines to understand the code that humans write with these languages, special pieces of software called compilers and interpreters are designed to "explain" what these languages are saying in a form that a computer can understand. This being so, some languages are compiled and others are interpreted. What this means is that compiled languages are compiled through compilers and interpreted languages become understandable to the CPU through interpreters.
Compiled languages have some advantages over interpreted languages, some of which are vital when it comes to games . One of these advantages is speed. As compiled languages are converted to the computer's native machine code at an earlier stage, there is no translating necessary when the program is being run. Interpreted languages like ActionScript are generally slower because they must be translated while the script is being executed. This overhead causes a significant slowdown .
Internet Explorer is an excellent example of a compiled stand-alone executable program. It was built with another language, such as C++.
One thing you must know about interpreters is that when you give your code to someone else to run, he or she must also have that darn interpreter. A nice thing about Flash is that millions of Internet users on cross-platforms have the Flash Player installed. The Flash Player not only plays Flash movies but also interprets our wonderful ActionScript language. But Macromedia didn't stop there. Their Flash Player can actually compile the Flash movie into a stand-alone projector file. This will allow anyone without a Flash Player to view the movie. As virtually everyone with a computer has the Flash Player installed, the only time I would use the projector is an instance in which a user doesn't have an updated player.
Now that you have a basic idea of what programming is, let's move on and expand your knowledge of what ActionScripts are. ActionScripts fall into the category of computer programs but their execution process is completely different from a stand-alone compiled program. As we move through the chapter and pick up these essential concepts, I will get more ActionScript-specific with my text. Before you know it, you will be writing and showing off your own ActionScript games.
|[ LiB ]|