• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Hour 3. Learning to Program > How Computers Think

How Computers Think

Actually, computers don't think at all. They mindlessly follow instructions. They take these instructions very literally.

A Flash script is a list of instructions. However, it is best not to think of them as a list of instructions addressed to the computer but to the Flash runtime environment. Scripts tell Flash what to do.

When you look at a code listing, you can “play computer” by reading the code and predicting what the computer will do each step of the way.

To play computer, you pretend that you are the computer, or more specifically, that you are Flash. You read each line of the program and pretend that it is an instruction that you must carry out.

For instance, if you are supposed to jump from one frame in the Flash movie to another, you imagine that the Flash movie is now on the destination frame and waiting for the next instruction. You then read the next line and follow that instruction.

By playing computer, you can predict what your scripts will do. You can troubleshoot your scripts this way and fix problems in them before you even run the program once. Soon, playing computer will be something that you do naturally as you program. When you write a line of code, you will imagine what Flash will do with that instruction. As you write a whole script, you will constantly be checking your code by doing this.

Computer programs are like onions. Take a Flash movie, for example. It is a .swf file that runs inside the Flash plug-in. The Flash plug-in, in turn, is running inside your Web browser. The Web browser is running as an application inside your computer's operating system. The operating system uses a complex toolbox of programs to do things such as display pixels on the screen; this toolbox is running on the microprocessor inside your computer.

All these levels depend on the ones below; each level must support everything that runs on top of it. This makes for a complex and delicate system.

Fortunately, as an ActionScript programmer, you are shielded from everything but the top layer. You don't have to know how the microprocessor, operating system, or Web browser works. You don't even have to know how Flash works—just what it is capable of doing and how you go about doing it.

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint