Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 145

Programming actionscript 3.0
Table of Contents

Advertisement

The prototype chain, which was the only inheritance mechanism in previous versions of
ActionScript, serves only a secondary role in ActionScript 3.0. The primary inheritance
mechanism, fixed property inheritance, is handled internally by the traits object. A fixed
property is a variable or method that is defined as part of a class definition. Fixed property
inheritance is also called class inheritance because it is the inheritance mechanism that is
associated with keywords such as
The prototype chain provides an alternative inheritance mechanism that is more dynamic
than fixed property inheritance. You can add properties to a class's prototype object not only
as part of the class definition, but also at run time through the class object's
property. Note, however, that if you set the compiler to strict mode, you may not be able to
access properties added to a prototype object unless you declare a class with the
keyword.
A good example of a class with several properties attached to the prototype object is the
Object class. The Object class's
assigned to properties of the Object class's prototype object. The following is an example of
how the declaration of these methods could, in theory, look (the actual implementation
differs slightly because of implementation details):
public dynamic class Object
{
prototype.toString = function()
{
// statements
};
prototype.valueOf = function()
{
// statements
};
}
As mentioned previously, you can attach a property to a class's prototype object outside the
class definition. For example, the
class definition, as follows:
Object.prototype.toString = function()
{
// statements
};
,
, and
class
extends
and
toString()
valueOf()
method can also be defined outside the Object
toString()
.
override
prototype
methods are actually functions
Advanced topics
dynamic
145

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents