MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT Reference Manual page 391

Actionscript reference guide
Hide thumbs Also See for FLASH MX 2004 - ACTIONSCRIPT:
Table of Contents

Advertisement

In almost all cases, the function call operator (
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 in the following:
myObject
myObject.myMethod(1, 2, 3);
In some situations, you may 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
This example uses
without storing the function in the object.
function MyObject() {
}
function MyMethod(obj) {
trace("this == obj? " + (this == obj));
}
var obj = new MyObject();
MyMethod.call(obj, obj);
The
action sends the following code to the Output panel:
trace()
this == obj? true
Function.prototype
Availability
Flash Player 5. If you are using ActionScript 2.0, you don't need to use this property; it reflects the
implementation of inheritance in ActionScript 1.
Usage
myFunction.prototype
Description
Property; in an ActionScript 1 constructor function, the
that is the prototype of the constructed class. Each instance of the class that is created by the
constructor function inherits all the properties and methods of the prototype object.
to point somewhere else; for example, if a function must
this
for the
null
thisObject
to make a function behave as a method of another object,
Function.call()
) can be used instead of this method. The
()
parameter to invoke a function as a regular
prototype
is set to
this
property refers to an object
Function.prototype
391

Advertisement

Table of Contents
loading

Table of Contents