176
ActionScript language elements
Example
The following example uses the subtraction assignment (
-=)
operator to subtract 10 from 5
and assign the result to the variable
x
:
var x:Number = 5;
var y:Number = 10;
x -= y; trace(x); // output: -5
The following example shows how strings are converted to numbers:
var x:String = "5";
var y:String = "10";
x -= y; trace(x); // output: -5
See also
- subtraction operator
: type operator
[ modifiers ] var variableName
:
type
function functionName ()
:
type { ... }
function functionName
(
parameter1
:
type , ... , parameterN
:
type
)
[
:
type ]{
... }
Used for strict data typing; this operator specifies the variable type, function return type, or
function parameter type. When used in a variable declaration or assignment, this operator
specifies the variable's type; when used in a function declaration or definition, this operator
specifies the function's return type; when used with a function parameter in a function
definition, this operator specifies the variable type expected for that parameter.
Types are a compile-time-only feature. All types are checked at compile time, and errors are
generated when there is a mismatch. Mismatches can occur during assignment operations,
function calls, and class member dereferencing using the dot (
.
) operator. To avoid type
mismatch errors, use strict data typing.
Types that you can use include all native object types, classes and interfaces that you define,
and Function and Void. The recognized native types are Boolean, Number, and String. All
built-in classes are also supported as native types.
Availability:
ActionScript 1.0; Flash Lite 2.0
Operands
variableName :
Object
- An identifier for a variable.
type
A native data type, class name
that you have defined, or interface name.
functionName
An identifier for a function.
parameter
An identifier for a function parameter.
Summary of Contents for FLASHLITE2 ACTIONSCRIPT-LANGUAGE
Page 1: ...Flash Lite 2 x ActionScript Language Reference...
Page 22: ...22 Contents...
Page 244: ...244 ActionScript language elements...
Page 760: ...760 ActionScript classes...