About Statements - MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

To learn what these names are, refer to the ActionScript 2.0 Language Reference, and search the
Help panel for additional instructional and usage sections in this book (Learning ActionScript
2.0 in Flash).

About statements

A statement is an instruction you give the FLA file to do something, such as to perform a
particular action. For example, you can use a conditional statement to determine whether
something is true or exists. Then your code might execute actions that you specify, such as
functions or expressions, based on whether the condition is true or not.
For example, the
statement is a conditional statement and evaluates a condition to
if
determine the next action that should occur in your code.
// if statement
if (condition) {
// statements;
}
Another example is the
which it executes.
There are many different ways for you to format or write ActionScript. You might differ from
someone else who writes ActionScript in the way you form syntax, such as the way you space
out your statements or where you put curly braces (
several different ways you can form statements without breaking your code, there are some
general guidelines you can follow to write well-formed ActionScript.
Place only one statement on a line to increase the readability of your ActionScript.
following example shows the recommended and not recommended statement usage:
theNum++;
// recommended
theOtherNum++;
// recommended
aNum++; anOtherNum++;
Assign variables as separate statements.
var myNum:Number = (a = b + c) + d;
This ActionScript embeds an assignment within the code, which is difficult to read. If you
assign variables as separate statements, it improves readability, as the following example shows:
var a:Number = b + c;
var myNum:Number = a + d;
The following sections show you how to form specific statements in ActionScript. For
information on writing and formatting events, see
page
329.
statement, which returns a result as a value of the function in
return
// not recommended
Consider the following ActionScript example:
) in your code. Even though there are
{}
Chapter 10, "Handling Events," on

About statements

The
141

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents