User Guide
Object 995
The following code can then be placed in a FLA file and will function the same way as it does
in the previous examples:
var myBook:Book = new Book();
myBook.bookcount = 5;
trace("You ordered "+myBook.bookcount+" copies of "+myBook.bookname);
See also
get statement, set statement
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
Example
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
See also
instanceof operator