
CHAPTER 2
20
Your methods may take required or optional arguments. To make any of the arguments optional, assign default
values to them, as the following example shows:
override public validate(value:Object = null,
supressEvents:Boolean = false):ValidationResultEvent {
// Method definition
}
If the method takes a variable number of arguments, use the “...” syntax, as the following example shows:
function foo(n:Number, ... rest):void {
// Method definition
}
Flex creates an Array called rest for the optional arguments. Therefore, you can determine the number of
arguments passed to the method by using
rest.length, and access the arguments by using ...