Game Development Reference
In-Depth Information
A little more about AS3.0 and the Flash Player
At the end of this process, you have a SWF file that you can take to any computer and run, as long
as the Flash Player is also installed on that same computer. The fact that the SWF file needs the help
of the Flash Player to run is very important. As a game designer, you need to know why this is and
the kinds of limitations it might impose on you. Let's take a closer look at what's going on behind the
scenes when you publish a SWF file.
AS3.0 is a type of high-level programming language . High-level programming languages, such as
Java, C++, and Visual Basic, are designed so that humans can easily read, write, and understand them.
They use real English words such as function and class , and use elements of English grammar such as
quotation marks and semicolons. But computers don't understand English. Try asking your computer
for help with the dishes this evening, and I expect you'll get nothing but a stony silence (if not, let
someone, hopefully a professional, know about it!).
At their most basic level, computers, understand only a binary language of 1s and 0s. So all the AS3.0
code has to be translated into binary code so the computer can understand it. Fortunately, you don't
have to do that manually, so you can put away that pencil and paper. Flash has a built-in compiler (a
software component that translates code) to do the job for you.
Keep in mind that, unlike writing a program in a language such as C++ or Visual Basic, Flash's compiler
doesn't compile your code so it's directly readable by your computer's central processing unit (CPU),
which is your computer's main “brain.” It compiles it only so that it can be read by the Flash Player
Before you can run any of your AS3.0 programs, the Flash Player software has to be installed on
your system because it's the job of the Flash Player to interpret your code to the CPU. Because of
this, AS3.0, like Java, is known as an interpreted programming language . Interpreted languages use
a piece of software known as a virtual machine , which acts as an interpreter between the CPU and
your program. The Flash Player is AS3.0's virtual machine.
Interpreted languages have a number of advantages over languages that compile directly to the CPU.
Most importantly, it means that your programs will run flawlessly and exactly the same way on any
operating system (Windows, Linux, or OS X) that has the Flash Player installed. You only need to write
your code once, and the Flash Player, which is written for each operating system that it's available for,
will take care of the job of making sure your code runs properly. The other advantage is that the Flash
Player protects the computer it's running on from any code that you might have written that could
accidentally freeze or crash your system. All this tends to make interpreted languages very convenient
and reliable languages to program with.
One major disadvantage with interpreted languages, however, is in the area of performance. Imagine
visiting a foreign country where you don't speak the language, but instead are accompanied by a trans-
lator who painstakingly translates every word you say and then translates each reply back into English.
It would be a very slow and tedious process. Unfortunately, this is exactly what's happening between
the Flash Player and the CPU when you run your AS3.0 programs. How slow is it? Exact numbers are
hard to come by, but a reasonable estimate might be 10 to 20 times slower than if the code were
compiled as binary machine language and running directly on the CPU. (By “slow,” I mean exactly how
quickly the CPU can process each instruction or calculation your program asks it to perform.)
Search Nedrilad ::

Custom Search