MACROMEDIA FLEX-FLEX ACTIONSCRIPT LANGUAGE Reference page 226

Actionscript language reference
Table of Contents

Advertisement

var
Availability
Flash Player 5.
Usage
var variableName [= value1] [...,variableNameN [=valueN]]
Parameters
variableName
The value assigned to the variable.
value
Returns
Nothing.
Description
Statement; used to declare local variables.
If you declare variables inside a function, the variables are local. They are defined for the function
and expire at the end of the function call. More specifically, a variable defined using
the code block containing it. Code blocks are demarcated by curly braces ({}).
You cannot declare a variable scoped to another object as a local variable (for more information,
see
"Scoping and declaring variables" on page
my_array.length = 25;
var my_array.length = 25; // syntax error
When you use
var
typing" on page
Note: You must also use var when declaring properties inside class definitions in external scripts.
Class files also support public, private, and static variable scopes. See
ActionScript 2.0" on page
Example
The following ActionScript creates a new array of product names.
onto the end of the array. If you want to use strict typing, it is essential that you use the
keyword. Without
var product_array:Array = new Array("MX 2004", "Studio", "Dreamweaver",
"Flash", "ColdFusion", "Contribute", "Breeze");
product_array.push("Flex");
trace(product_array);
// output: MX 2004,Studio,Dreamweaver,Flash,ColdFusion,Contribute,Breeze,Flex
226
Chapter 5: ActionScript Core Language Elements
ActionScript Core Language Elements
An identifier.
// ok
, you can strictly type the variable. For more information, see
24.
45, and see
private
before
var
product_array
28):
"Creating Custom Classes with
,
,
public
and
static
Array.push
, you get errors when you try to use strict typing.
CHAPTER 5
is local to
var
"Strict data
.
adds an element
var

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?

This manual is also suitable for:

Flex

Table of Contents