Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 101

Programming actionscript 3.0
Table of Contents

Advertisement

You should also be careful to avoid using the string
because it will shadow the
is rewritten so that an
function body refer to the parameter rather than the
produces no output:
function traceArgArray(x:int, arguments:int):void
{
for (var i:uint = 0; i < arguments.length; i++)
{
trace(arguments[i]);
}
}
traceArgArray(1, 2, 3);
// no output
The
object in previous versions of ActionScript also contained a property named
arguments
, which is a reference to the function that called the current function. The
caller
property is not present in ActionScript 3.0, but if you need a reference to the calling function,
you can alter the calling function so that it passes an extra parameter that is a reference to
itself.
The ... (rest) parameter
ActionScript 3.0 introduces a new parameter declaration called the ... (rest) parameter. This
parameter allows you to specify an array parameter that accepts any number of comma-
delimited arguments. The parameter can have any name that is not a reserved word. This
parameter declaration must be the last parameter specified. Use of this parameter makes the
object unavailable. Although the ... (rest) parameter gives you the same
arguments
functionality as the
arguments
functionality similar to that provided by
not need to use
arguments.callee
The following example rewrites the
instead of the
arguments
function traceArgArray(... args):void
{
for (var i:uint = 0; i < args.length; i++)
{
trace(args[i]);
}
}
traceArgArray(1, 2, 3);
object. For example, if the function
arguments
parameter is added, the references to
arguments
array and
arguments.length
arguments.callee
before using the ... (rest) parameter.
traceArgArray()
object:
as a parameter name
"arguments"
arguments
object. The following code
arguments
property, it does not provide
. You should ensure that you do
function using the ... (rest) parameter
traceArgArray()
in the
caller
Functions
101

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents