Flash 8 Documentation |
|||
| ActionScript 2.0 Language Reference > ActionScript classes > Object > constructor (Object.constructor property) | |||
public constructor : Object
Reference to the constructor function for a given object instance. The constructor property is automatically assigned to all objects when they are created using the constructor for the Object class.
Availability: ActionScript 1.0; Flash Player 5
The following example is a reference to the constructor function for the myObject object.
var my_str:String = new String("sven");
trace(my_str.constructor == String); //output: true
If you use the instanceof operator, you can also determine if an object belongs to a specified class:
var my_str:String = new String("sven");
trace(my_str instanceof String); //output: true
However, in the following example the Object.constructor property converts primitive data types (such as the string literal seen here) into wrapper objects. The instanceof operator does not perform any conversion, as seen in the following example:
var my_str:String = "sven"; trace(my_str.constructor == String); //output: true trace(my_str instanceof String); //output: false
Version 8