Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 146

Programming actionscript 3.0
Table of Contents

Advertisement

Unlike fixed property inheritance, however, prototype inheritance does not require the
keyword if you want to redefine a method in a subclass. For example. if you want to
override
redefine the
valueOf()
First, you can define a
definition. The following code creates a subclass of Object named Foo and redefines the
method on Foo's prototype object as part of the class definition. Because every
valueOf()
class inherits from Object, it is not necessary to use the
dynamic class Foo
{
prototype.valueOf = function()
{
return "Instance of Foo";
};
}
Second, you can define a
definition, as shown in the following code:
Foo.prototype.valueOf = function()
{
return "Instance of Foo";
};
Third, you can define a fixed property named
technique differs from the others in that it mixes fixed property inheritance with prototype
inheritance. Any subclass of Foo that wants to redefine
keyword. The following code shows
class Foo
{
function valueOf() {
return "Instance of Foo";
}
}
146
Object-Oriented Programming in ActionScript
method in a subclass of the Object class, you have three options.
method on the subclass's prototype object inside the class
valueOf()
method on Foo's prototype object outside the class
valueOf()
valueOf()
keyword.
extends
as part of the Foo class. This
valueOf()
valueOf()
defined as a fixed property in Foo:
must use the
override

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents