The ActionScript Statements

Now that you know how a typical statement is formed, skim Table 6.1 to acquaint yourself with some of the things that ActionScript statements do.

Table 6-1. The ActionScript Statements

Statement

Syntax

Use

break

break;

Cancels a loop

call

call (frame);

Executes the script on a remote frame

continue

continue;

Restarts the current loop

do-while

do {
   statements
} while (expression);

A variation of a while loop

empty statement

;

Holds a place where a statement is expected, and used with evaluate in novice mode

for

for (init; test; increment) {
   statements
}

Executes some code repetitively (a for loop)

for-in

for (property in object) {
   statements
}

Enumerates the properties of an object

function

function name(parameters) {
   statements
}

Declares a function

if-else if-else

if (expression) {
   statements
} else if (expression) {
   statements
} else {
   statements
}

Executes some code based on a condition or a series of conditions

ifFrameLoaded

ifFrameLoaded (frame) {
   statements
}

Executes some code if a certain frame has loaded; deprecated in Flash 5

return

return;
return expression;

Exits a function or returns a value from a function

set

set (variable, value);

Assigns a value to a dynamically named variable

var

var variableName;
var variableName = expression;

Declares and optionally initializes a variable

while

while (expression) {
   statements
}

Executes some code repetitively (a while loop)

with

with (objectName ...

Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.