ActionScript 3.0 sports a new feature called
the
rest( ... ) operator. This allows us to
send a comma delimeted array of arguments to our custom functions for
processing. The rest operator is represented by three consecutive dots
called triple dot( ... ).
Using the rest operator to send array
data into functions
function myFunction(... argArray):void {
for (var i:uint = 0; i < argArray.length; i++) {
trace(argArray[i]);
}
}
myFunction("Joe", "Betty", "Suzy", "William");
Joe
Betty
Suzy
William
Using rest along with other arguments.
(rest ... ) must come last.
function myFunction(var1:String, var2:String, ... argArray):void {
trace(var1 + " is first in line");
trace(var2 + " is second in line");
for (var i:uint = 0; i < argArray.length; i++) {
trace(argArray[i]);
}
}
myFunction("Joe", "Betty", "Suzy", "William");
Joe is first in line
Betty is second in line
Suzy
William