![MACROMEDIA Flash Lite 2 Скачать руководство пользователя страница 558](http://html1.mh-extra.com/html/macromedia/flash-lite-2/flash-lite-2_reference_687553558.webp)
558
ActionScript classes
The following trace statements show that the
__proto_
property of both instances refers to
the
prototype
property of the Circle class.
trace(Circle.prototype == oneCircle.__proto__); // Output: true
trace(Circle.prototype == twoCircle.__proto__); // Output: true
See also
prototype (Object.prototype property)
prototype (Object.prototype property)
public static prototype :
Object
A reference to the superclass of a class or function object. The
prototype
property is
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
prototype
property is shared by all instances of the class, and is
accessible only as a class property. Instances of your custom class cannot directly access the
prototype
property, but can access it through the
__proto__
property.
Availability:
ActionScript 1.0; Flash Lite 2.0
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
prototype
property of the Circle class points to
its superclass Shape. The identifier
Shape
refers to the constructor function of the Shape class.
trace(Circle.prototype.constructor == Shape); // Output: true
Содержание Flash Lite 2
Страница 1: ...Flash Lite 2 x ActionScript Language Reference...
Страница 22: ...22 Contents...
Страница 244: ...244 ActionScript language elements...
Страница 760: ...760 ActionScript classes...