MACROMEDIA FLEX-FLEX ACTIONSCRIPT LANGUAGE Reference page 239

Actionscript language reference
Table of Contents

Advertisement

Description
Property; the number of parameters actually passed to a function.
Example
The following ActionScript includes a function called
of arguments that are passed into the function. Although the method expects three arguments,
you can pass as many arguments as you want.
function getArgLength(param_arg1:String, param_arg2:String, param_arg3:String)
{
return (arguments.length);
}
trace(getArgLength("one", "two", "three")); // output: 3
trace(getArgLength("one", "two")); // output: 2
trace(getArgLength("one", "two", "three", "four")); // output: 4
In the following example, the function called
sum. The function uses a
value is added to the
function listSum():Number {
var sum:Number = 0;
for (var i = 0; i<arguments.length; i++) {
if (!isNaN(Number(arguments[i]))) {
sum += parseFloat(arguments[i]);
}
}
return sum;
}
trace(listSum(100, 200, 300, 7)); // output: 607
loop to examine each argument passed. If the value is a number, the
for
variable. At the end of the function, the value of
sum
getArgLength
adds the values passed to it and returns the
listSum
, which returns the number
is returned.
sum
arguments.length
239

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?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flex

Table of Contents