You are on page 1of 9

Core Language

Fundamentals
ActionScript 3.0 in Flash
Content
Miscellaneous Basics
Variables and Data Types
Miscellaneous Basics
Execution order
In general, ActionScript executes in a top-to-bottom, left-
to-right order—that is, each line executes one after another,
working from left to right.
Several things can change this order in subtle ways, but it’s
basically a reliable rule of thumb.
For example, subroutines of one type or another can be called
in the middle of a script, causing the execution order of the
original script to pause while the remote routine is executed.
When the subroutine has completed, the execution of the
original script continues where it left off.
Miscellaneous Basics
Use of the semicolon(;)
The official use of the semicolon in ActionScript is to
execute more than one instruction on a single line.
This is rare in the average script, and we will look at this
technique when discussing loops.
However, the semicolon is also used to indicate the end
of a line. This is not required, but it is recommended for
clarity and to ease any possible transition into learning
other languages in which the semicolon at the end of a
line is required.
Miscellaneous Basics
Evaluating an expression
It’s helpful to note that you are usually not solving an
equation when you see an expression with like values on
the left and right of an equal sign.
For example if you see something like x = x + 1, it is
unlikely that you will be solving for the value of x.
Instead, this line is assigning a new value to x by adding
1 to its previous value.
Use of the trace command
Variables and Data Types
Variables are best described as containers into which
you place information for later recall.
You need only create a variable with a unique name, so
it can be referenced separately from other variables
and the ActionScript language itself, and then
populate it with a value.
A simple example is remembering the number 1 with
the following:
myVariable = 1;
Variables and Data Types
If you try to perform a mathematical operation on a
passage of text, Flash will issue a warning so you can
correct the problem.
Variables and Data Types
To do this, Flash must be told what you intend to store
in each variable.
This is accomplished by declaring the variable by
preceding its first use with the var keyword, and citing
the type of data to be stored therein by following the
name of the variable with a colon (:) and data type.
For instance, the previous example of remembering
the number 1 should be written this way:
var myVariable:Number = 1;

You might also like