03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

constructor (Object.constructor property)<br />

public constructor : Object<br />

<strong>Reference</strong> to the constructor function for a given object instance. The constructor property<br />

is automatically assigned to all objects when they are created using the constructor for the<br />

Object class.<br />

Availability: <strong>ActionScript</strong> 1.0; Flash Player 5<br />

Example<br />

The following example is a reference to the constructor function for the myObject object.<br />

var my_str:String = new String("sven");<br />

trace(my_str.constructor == String); //output: true<br />

If you use the instanceof operator, you can also determine if an object belongs to a specified<br />

class:<br />

var my_str:String = new String("sven");<br />

trace(my_str instanceof String); //output: true<br />

However, in the following example the Object.constructor property converts primitive<br />

data types (such as the string literal seen here) into wrapper objects. The instanceof operator<br />

does not perform any conversion, as seen in the following example:<br />

var my_str:String = "sven";<br />

trace(my_str.constructor == String); //output: true<br />

trace(my_str instanceof String); //output: false<br />

See also<br />

instanceof operator<br />

hasOwnProperty (Object.hasOwnProperty method)<br />

public hasOwnProperty(name:String) : Boolean<br />

Indicates whether an object has a specified property defined. This method returns true if the<br />

target object has a property that matches the string specified by the name parameter, <strong>and</strong><br />

false otherwise. This method does not check the object's prototype chain <strong>and</strong> returns true<br />

only if the property exists on the object itself.<br />

Availability: <strong>ActionScript</strong> 1.0; Flash Player 6<br />

Parameters<br />

name:String -<br />

Object 1009

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!