function
Availability
Flash Player 5.
Usage
function functionname ([parameter0, parameter1,...parameterN]){
statement(s)
}
function ([parameter0, parameter1,...parameterN]){
statement(s)
}
Parameters
functionname
An identifier that represents a parameter to pass to the function. This parameter is
parameter
optional.
statement(s)
Returns
Usage 1: Nothing.
Usage 2: A reference to the anonymous function.
Description
Statement; comprises a set of statements that you define to perform a certain task. You can define
a function in one location and invoke, or call, it from different scripts in a SWF file. When you
define a function, you can also specify parameters for the function. Parameters are placeholders
for values on which the function operates. You can pass different parameters to a function each
time you call it so you can reuse a function in different situations.
Use the
statement in a function's
return
a value.
You can use this statement to define a
and
statement(s)
executed. Forward referencing is permitted; within the same script, a function may be declared
after it is called. A function definition replaces any prior definition of the same function. You can
use this syntax wherever a statement is permitted.
You can also use this statement to create an anonymous function and return a reference to it. This
syntax is used in expressions and is particularly useful for installing methods in objects.
For additional functionality, you can use the
Some common uses of the
number of parameters and creating a recursive anonymous function.
308
Chapter 2: ActionScript Language Reference
The name of the new function. This parameter is optional.
Any ActionScript instruction you have defined for the body of the
function
. When a script calls a function, the statements in the function's definition are
arguments object
ActionScript Language Reference
to cause a function to generate, or return,
statement(s)
with the specified
arguments object
are creating a function that accepts a variable
CHAPTER 2
function
,
functionname
parameters
in your function definition.
.
,
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