EasyManua.ls Logo

MACROMEDIA FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE - Page 118

MACROMEDIA FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE
780 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
118 ActionScript language elements
Note: Flash Lite 2.0 supports the addition (+) operator for adding numeric expressions and
concatenating strings. Flash Lite 1.x only supports the addition (
+) operator for adding
numeric expressions (such as
var1 = 1 + 2 // output: 3). For Flash Lite 1.x, you must
use the
add operator to concatenate strings.
Availability: ActionScript 1.0; Flash Lite 1.0 - In Flash 4,
+ is a numeric operator only. In
Flash Player 5 and later,
+ is either a numeric operator or a string concatenator depending on
the data type of the parameter. Flash 4 files that are brought into the Flash 5 or later authoring
environment undergo a conversion process to maintain data type integrity. The following
example illustrates the conversion of a Flash 4 file that contains a numeric quality comparison:
Flash 4 file:
x + y
Converted Flash 5 or later file: Number(x) + Number(y)
Operands
expression1 - A number or string.
expression2 - A number or string.
Returns
Object - A string, integer, or floating-point number.
Example
Usage 1: The following example concatenates two strings and displays the result in the
Output panel.
var name:String = "Cola";
var instrument:String = "Drums";
trace(name + " plays " + instrument); // output: Cola plays Drums
Note: Flash Lite 1.x does not support the addition (+) operator for concatenating strings. For
Flash Lite 1.x, you must use the
add operator to concatenate strings.
Usage 2: This statement adds the integers 2 and 3 and displays the resulting integer, 5, in the
Output panel:
trace(2 + 3); // output: 5
This statement adds the floating-point numbers 2.5 and 3.25 and displays the resulting
floating-point number, 5.75, in the Output panel
trace(2.5 + 3.25); // output: 5.75

Table of Contents

Related product manuals