Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 100

Programming actionscript 3.0
Table of Contents

Advertisement

ActionScript 3.0 allows function calls to include more parameters than those defined in the
function definition, but will generate a compiler error in strict mode if the number of
parameters is less than the number of required parameters. You can use the array aspect of the
object to access any parameter passed to the function, whether or not that
arguments
parameter is defined in the function definition. The following example uses the
array along with the
arguments.length
function:
traceArgArray()
function traceArgArray(x:int):void
{
for (var i:uint = 0; i < arguments.length; i++)
{
trace(arguments[i]);
}
}
traceArgArray(1, 2, 3);
// output:
// 1
// 2
// 3
The
arguments.callee
You can use it to add flexibility to your code. If the name of a recursive function changes over
the course of your development cycle, you need not worry about changing the recursive call in
your function body if you use
property is used in the following function expression to enable recursion:
arguments.callee
var factorial:Function = function (x:uint)
{
if(x == 0)
{
return 1;
}
else
{
return (x * arguments.callee(x - 1));
}
}
trace(factorial(5)); // 120
If you use the ... (rest) parameter in your function declaration, the
be available to you. Instead, you must access the parameters using the parameter names that
you declared for them.
100
ActionScript Language and Syntax
property to trace all the parameters passed to the
property is often used in anonymous functions to create recursion.
arguments.callee
instead of the function name. The
arguments
arguments
object will not

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents