Function.toString( ) Method

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Chapter 18.  ActionScript Language Reference
Function.toString( ) Method Flash 5

returns a string representation of the function object
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());           // Displays: [type Function] trace(typeof moveClipTo);               // Displays: function trace(moveClipTo instanceof Function);  // Displays: true

To provide a more descriptive return value for toString( ), you can override the toString( ) method for the function:

moveClipTo.toString = function () {   return "moveClipTo function"; };     trace(moveClipTo.toString());  // Displays: moveClipTo function

See Also

instanceof, Object.toString( ), typeof



    ActionScript for Flash MX. The Definitive Guide
    ActionScript for Flash MX: The Definitive Guide, Second Edition
    ISBN: 059600396X
    EAN: 2147483647
    Year: 2002
    Pages: 780
    Authors: Colin Moock

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net