MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 769

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

Place braces around each statement when it is part of a control structure (
even if it contains only a single statement. The following example shows code that is
written poorly:
// bad
if (numUsers == 0)
trace("no users found.");
Although this code validates, it is poorly written because it lacks braces around the statements.
In this case, if you add another statement after the
regardless of whether the
// bad
var numUsers:Number = 5;
if (numUsers == 0)
trace("no users found.");
trace("I will execute");
Executing the code despite the
reason, add braces, as shown in the following example:
var numUsers:Number = 0;
if (numUsers == 0) {
trace("no users found");
}
When you write a condition, don't add the redundant
if (something == true) {
//statements
}
If you are compare against
.
if(!something)
Writing a for statement
You can write the
for
for (init; condition; update) {
// statements
}
The following structure demonstrates the
var i:Number;
for (var i = 0; i<4; i++) {
myClip.duplicateMovieClip("newClip" + i + "Clip", i + 10, {_x:i*100,
_y:0});
}
Remember to include a space following each expression in a
variable equals 0:
numUsers
variable can lead to unexpected results. For this
numUsers
, you could use
false
statement using the following format:
for
statement, the code executes
trace
in your code, as follows:
==true
if (something==false)
statement:
statement.
for
Formatting ActionScript syntax
or
),
if..else
for
or
769

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