MACROMEDIA FLEX-FLEX ACTIONSCRIPT LANGUAGE Reference page 293

Actionscript language reference
Table of Contents

Advertisement

Function.call()
Availability
Flash Player 6.
Usage
myFunction.call(thisObject:Object, parameter1, ..., parameterN)
Parameters
An object that specifies the value of
thisObject
A parameter to be passed to the
parameter1
more parameters.
parameterN
Returns
Nothing.
Description
Method; invokes the function represented by a Function object. Every function in ActionScript is
represented by a Function object, so all functions support this method.
In almost all cases, the function call (
function call operator produces code that is concise and readable. This method is primarily useful
when the
parameter of the function invocation needs to be explicitly controlled. Normally,
this
if a function is invoked as a method of an object, within the body of the function,
as shown in the following example:
myObject,
myObject.myMethod(1, 2, 3);
In some situations, you might want
be invoked as a method of an object, but is not actually stored as a method of that object:
myObject.myMethod.call(myOtherObject, 1, 2, 3);
You can pass the value
function and not as a method of an object. For example, the following function invocations
are equivalent:
Math.sin(Math.PI / 4)
Math.sin.call(null, Math.PI / 4)
Example
The following example uses
object, without storing the function in the object:
function myObject() {
}
function myMethod(obj) {
trace("this == obj? " + (this == obj));
}
) operator can be used instead of this method. The
()
to point somewhere else; for example, if a function must
this
for the
null
thisObject
Function.call()
within the function body.
this
. You can specify zero or
myFunction
parameter to invoke a function as a regular
to make a function behave as a method of another
is set to
this
Function.call()
293

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flex

Table of Contents