MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT Reference Manual page 388

Actionscript reference guide
Hide thumbs Also See for FLASH MX 2004 - ACTIONSCRIPT:
Table of Contents

Advertisement

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. These parameters
parameter
are optional.
statement(s)
Returns
Nothing.
Description
Statement; comprises a set of statements that you define to perform a certain task. You can
declare, or define, a function in one location and call, or invoke, 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. This lets you reuse one function in many different situations.
Use the
return
a value.
Usage 1: Declares a
. When a function is called, the function declaration is invoked. Forward
statement(s)
referencing is permitted; within the same Action list, a function may be declared after it is called.
A function declaration replaces any prior declaration of the same function. You can use this syntax
wherever a statement is permitted.
Usage 2: Creates an anonymous function and returns it. This syntax is used in expressions, and is
particularly useful for installing methods in objects.
Example
Usage 1: The following example defines the function
returns the
square(x*x)
the function declaration may appear after using the function.
y=sqr(3);
function sqr(x) {
return x*x;
}
388
Chapter 12: ActionScript Dictionary
The name of the new function.
Any ActionScript instruction you have defined for the body of the
action in a function's
statement(s)
with the specified
function
of the parameter. If the function is declared and used in the same script,
to cause a function to return, or generate,
,
functionname
parameters
, which accepts one parameter and
sqr
.
function
, and

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004 - ACTIONSCRIPT and is the answer not in the manual?

Questions and answers

Table of Contents