Object Class

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

the basis for all other classes and the basis for generic objects

Constructor

new Object()

Properties

constructor

A reference to the class constructor function used to create the object.

_ _proto_ _

A reference to the prototype property of the object's constructor function.

Class Methods

The following method is invoked through the Object class itself, not through an instance of the Object class:

registerClass( )

Assign a constructor for a movie clip symbol.

Methods

The following are instance-level methods of the Object class.

addProperty( )

Define a getter/setter property for an object or class.

hasOwnProperty( )

Check whether a property is defined directly on an object.

toString( )

Convert the value of the object to a string.

unWatch( )

Remove an existing watchpoint.

valueOf( )

Retrieve the primitive value of the object, if one exists.

watch( )

Create a watchpoint to filter property assignment.

Description

The Object class is the base class of the ActionScript object model. Object is used for two general purposes: as a constructor for creating new, generic objects, and as a superclass upon which to base new classes. All classes in ActionScript, whether user-defined or built-in, are descendants of the Object class. All instances of all classes therefore inherit the properties and methods of Object (though some classes override those properties). However, the class method Object.registerClass( ) is accessed directly as a method of the Object class's constructor, Object, not through an instance of the class.

To create a generic object of the Object class directly in our code without using a constructor, we can use an object literal just as we might use a string literal or an array literal. An object literal is a series of comma-separated property name/value pairs, enclosed in curly braces. Here's the general syntax:

{ property1: value1, property2: value2, property3: value3 }

The names of properties in an object literal must be legal identifiers, as described in Chapter 15. The values can be any valid expression. For example:

// An object literal with two numeric properties myObject = { x: 30, y: 23 }; // Set the x property's value using a complex expression myOtherObject = { x: Math.floor(Math.random() * 50 + 1) };

Because object literals always create generic, anonymous objects, they typically are used when we need object-formatted data temporarily, such as when invoking Sound.setTransform( ), Color.setTransform( ), or MovieClip.localToGlobal( ).

See Also

Chapter 12



    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