
Function.toString() Method
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Alphabetical Language Reference
|
533
this.funcName = name;
};
Function.prototype.toString = Function.prototype.getName;
// Usage:
function squareNum (x) {
return x * x;
}
squareNum.setName("squareNum");
trace(squareNum); // Displays: squareNum
// (instead of [type Function])
For a full discussion of prototype’s role in object-oriented ActionScript programming, see
Chapter 12. Within the advanced developer community, the
prototype property is the
focus of a lively debate on superclass assignment methodology. See “Advanced Issues with
Standard SuperClass Assignment” in Chapter 12.
See Also
Object.constructor, Object.__proto__; Chapter 12
Function.toString() Method
returns a string representation of the function object
Flash 5
theFunction.toString()
Returns
A string representing the function object.
Description
The toString( ) method returns a string describing theFunction. By default, all functions
return the string “[type Function]”. Checking the return value of toString( ) can be useful
during debugging, as it distinguishes function objects from other objects. The instanceof
and typeof operators can also be used to determine the datatype of a Function object. For
example:
function moveClipTo (newX, newY) {
this._x = newX;
this._y = newY;
}
trace(moveClipTo.toString()); // ...