Prototype (Object.prototype Property) - MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE Reference

Actionscript 2.0 language reference
Table of Contents

Advertisement

prototype (Object.prototype property)

public static prototype : Object
A reference to the superclass of a class or function object. The
automatically created and attached to any class or function object you create. This property is
static in that it is specific to the class or function you create. For example, if you create a
custom class, the value of the
accessible only as a class property. Instances of your custom class cannot directly access the
property, but can access it through the
prototype
Availability: ActionScript 1.0; Flash Player 6
Example
The following example creates a class named Shape and a subclass of Shape named Circle.
// Shape class defined in external file named Shape.as
class Shape {
function Shape() {}
}
// Circle class defined in external file named Circle.as
class Circle extends Shape{
function Circle() {}
}
The Circle class can be used to create two instances of Circle:
var oneCircle:Circle = new Circle();
var twoCircle:Circle = new Circle();
The following trace statement shows that the
to its superclass Shape. The identifier
class.
trace(Circle.prototype.constructor == Shape); // Output: true
The following trace statement shows how you can use the
property together to move two levels up the inheritance hierarchy (or prototype
__proto__
chain). The
Circle.prototype.__proto__
the Shape class.
trace(Circle.prototype.__proto__ == Shape.prototype); // Output: true
See also
__proto__ (Object.__proto__ property)
property is shared by all instances of the class, and is
prototype
prototype
refers to the constructor function of the Shape
Shape
property contains a reference to the superclass of
prototype
property.
__proto__
property of the Circle class points
property and the
prototype
property is
Object
999

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