Flash CS4 Professional ActionScript 2.0

Specifying the object to which a function is applied using Function.apply() in ActionScript 1.0

NOTE

 

Many Flash users can greatly benefit from using ActionScript 2.0, especially with complex applications. For information on using ActionScript 2.0, see Classes.

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.