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

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

For more information on the dot (
and array access operators" on page
see
"Formatting ActionScript syntax" on page
Semicolons and colons
ActionScript statements terminate with a semicolon (
following two lines of code:
var myNum:Number = 50;
myClip._alpha = myNum;
You can omit the semicolon character and the ActionScript compiler assumes that each line of
code represents a single statement. However, it is good scripting practice to use semicolons
because it makes your code more readable. When you click the Auto Format button in the
Actions panel or Script window, trailing semicolons are appended to the end of your
statements by default.
Using a semicolon to terminate a statement allows you to place more than one statement
on a single line, but doing so usually makes your code more difficult to read.
Another place you use semicolons is in
parameters, as shown in the following example. The example loops from 0 to 9 and then
displays each number in the Output panel:
var i:Number;
for (i = 0; i < 10; i++) {
trace(i); // 0,1,...,9
}
You use colons (:) in your code to assign data types to your variables. To assign a specific data
type to an item, specify its type using the
following example:
// strict typing of variable or object
var myNum:Number = 7;
var myDate:Date = new Date();
// strict typing of parameters
function welcome(firstName:String, myAge:Number) {
}
// strict typing of parameter and return value
function square(num:Number):Number {
var squared:Number = num * num;
return squared;
}
) operator and array access (
.
184. For information on white space and code formatting,
764.
) character, as demonstrated in the
;
loops. You use the semicolon to separate
for
keyword and post-colon syntax, as shown in the
var
) operators, see
"Using dot
[]
About language punctuators
125

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