Constructor (Object.constructor Property) - MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE Reference

Actionscript 2.0 language reference
Table of Contents

Advertisement

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
property
constructor
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
object.
myObject
var my_str:String = new String("sven");
trace(my_str.constructor == String); //output: true
If you use the
operator, you can also determine if an object belongs to a specified
instanceof
class:
var my_str:String = new String("sven");
trace(my_str instanceof String); //output: true
However, in the following example the
property converts primitive
Object.constructor
data types (such as the string literal seen here) into wrapper objects. The
operator
instanceof
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
Object
995

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents

Save PDF