802 Object-Oriented Programming with ActionScript 1.0
To invoke a function using the Function.call() method:
■ Use the following syntax:
myFunction.call(thisObject, parameter1, ..., parameterN)
The method takes the following parameters:
■ The parameter thisObject specifies the value of this within the function body.
■ The parameters parameter1..., parameterN specify parameters to be passed to
myFunction. You can specify zero or more parameters.
Specifying the object to which a function is applied
using Function.apply() in ActionScript 1.0
The Function.apply() method specifies the value of this to be used within any function
that ActionScript calls. This method also specifies the parameters to be passed to any
called function.
The parameters are specified as an Array object. This is often useful when the number of
parameters to be passed is not known until the script actually executes.
For more information, see
apply (Function.apply method) in the ActionScript 2.0
Language Reference.
To specify the object to which a function is applied using Function.apply():
■ Use the following syntax:
myFunction.apply(thisObject, argumentsObject)
The method takes the following parameters:
■ The parameter thisObject specifies the object to which myFunction is applied.
■ The parameter argumentsObject defines an array whose elements are passed to
myFunction as parameters.
NOTE
Many Flash users can greatly benefit from using ActionScript 2.0, especially with
complex applications. For information on using ActionScript 2.0, see Chapter 7,
“Classes,” on page 225.