User Guide

Syntax 13
Parameters (also called arguments) are placeholders that let you pass values to functions.
For example, the following
welcome() function uses two values it receives in the parameters
firstName and hobby:
function welcome(firstName:String, hobby:String):String {
var welcomeText:String = "Hello, " + firstName + ". I see you enjoy " + hobby
+".";
return welcomeText;
}
Packages
are directories that contain one or more class files and reside in a designated classpath
directory (see “Understanding the classpath” on page 64).
Properties are attributes that define an object. For example, length is a property of all arrays that
specifies the number of elements in the array.
Statements are language elements that perform or specify an action. For example, the return
statement returns a result as a value of the function in which it executes. The
if statement
evaluates a condition to determine the next action that should be taken. The
switch statement
creates a branching structure for ActionScript statements.
Target paths are hierarchical addresses of movie clip instance names, variables, and objects in a
SWF file. You can use a target path to direct an action at a movie clip or to get or set the value of
a variable or property. For example, the following statement is the target path to the
volume
property of the object named
stereoControl:
stereoControl.volume
Variables
are identifiers that hold values of any data type. Variables can be created, changed, and
updated. The values they store can be retrieved for use in scripts. In the following example, the
identifiers on the left side of the equal signs are variables:
var x:Number = 5;
var name:String = "Lolo";
var c_color:Color = new Color(mcinstanceName);
For more information on variables, see About variables” on page 27.
Syntax
As with all scripting languages, ActionScript has syntax rules that you must follow to create scripts
that can compile and run correctly. This section describes the elements that comprise
ActionScript syntax:
“Case sensitivity” on page 14
“Dot syntax” on page 14
“Curly braces” on page 15
“Semicolons” on page 15
“Parentheses” on page 16
“Comments” on page 16