: (type)
Availability
Flash Player 6.
Usage
[modifiers] var variableName:type
function functionName():type { ... }
function functionName(parameter1:type, ... , parameterN:type) [ :type ]{ ... }
Note: To use this operator, you must specify ActionScript 2.0 and Flash Player 6 or later in the Flash
tab of your FLA file's Publish Settings dialog box.
Parameters
variableName
A native data type, class name that you have defined, or interface name.
type
functionName
An identifier for a function parameter.
parameter
Description
Operator; 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. (For more information, see Appendix A, "Error Messages,"
in Using ActionScript in Flash.) Mismatches can occur during assignment operations, function
calls, and class member dereferencing using the dot (
use strict data typing (see "Strict data typing" in Using ActionScript in Flash).
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. For more information, see "About data types" in Using
ActionScript in Flash.
For information about operator precedence, see "Operator precedence and associativity" in Using
ActionScript in Flash.
Example
Usage 1: The following example declares a public variable named
and assigns an empty string to it:
var userName:String = "";
50
Chapter 2: ActionScript Language Reference
An identifier for a variable.
An identifier for a function.
) operator. To avoid type mismatch errors,
.
userName
whose type is String
Need help?
Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?
Questions and answers