
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
200
|
Chapter 9: Functions
viewVars(10); // In Flash Player 6, displays:
// x is 10
// y is undefined
// z is undefined
// (In Flash Player 5, undefined variables are displayed as a
// blank string in the Output window.)
When a function is called with more parameters than the declared number, excess
parameter values can be accessed using the arguments object. (Obviously, the excess
parameters can’t be accessed by name, as explicitly declared parameters can, because
their names were not declared.)
The arguments Object
During the execution of any function, the built-in arguments object gives us access to
the following:
• The number of parameters that were passed to the function
• An array containing each of those parameter values
• A reference to the function being executed
• A reference to the calling function, if any
The arguments object is really a special hybrid between an array and an object with
some other properties. In Flash 5, arguments was not an array instance. In Flash MX,
however, arguments is an instance of the Array class and therefore supports Array’s
methods and properties.
Retrieving parameter values from the arguments array
The arguments array lets us check the value of any function invocation argument,
whether or not that parameter is defined formally in the function’s