Object.constructor Property

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Chapter 18.  ActionScript Language Reference
Object.constructor Property Flash 5

a reference to the class constructor function used to create the object read/write
someObject.constructor

Description

The constructor property stores a reference to the constructor function that was used to create someObject. For example, the constructor property of a Date object is the Date constructor function:

now = new Date(); now.constructor =  = Date;       // Yields true

Note that in JavaScript, the constructor property is always read from someObject's constructor's prototype property (someObject._ _proto_ _.constructor). In Flash Player 6 and Flash Player 5, the constructor property is written directly to someObject so that it always faithfully refers to someObject's actual constructor function. For a complete discussion of this subtle deviation, see Section 12.7.3 in Chapter 12.

Usage

Overwriting an object's constructor property is not recommended, because it alters the natural structure of class inheritance.

See Also

Section 12.7.2 and Section 12.7.3



    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