Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 134

Programming actionscript 3.0
Table of Contents

Advertisement

To see how the other access control specifiers affect compilation and execution of the
preceding example, change the
or
after deleting or commenting out the following line from the
internal
class:
trace (myExt.testString);
Overriding variables not permitted
Properties that are declared with the
overridden. To override a property means to redefine the property in a subclass. The only type
of property that can be overridden are methods—that is, properties declared with the
keyword. Although you cannot override an instance variable, you can achieve
function
similar functionality by creating getter and setter methods for the instance variable and
overriding the methods. For more information, see
on page
135.
Overriding methods
To override a method means to redefine the behavior of an inherited method. Static methods
are not inherited and cannot be overridden. Instance methods, however, are inherited by
subclasses and can be overridden as long as the following two criteria are met:
The instance method is not declared with the
with an instance method, the
subclasses from overriding the method.
The instance method is not declared with the
class. If a method is marked as
keyword when defining an identically named method in the subclass because
override
the base class method will not be visible to the subclass.
To override an instance method that meets these criteria, the method definition in the
subclass must use the
method in the following ways:
The override method must have the same level of access control as the base class method.
Methods marked as internal have the same level of access control as methods that have no
access control specifier.
The override method must have the same number of parameters as the base class method.
The override method parameters must have the same data type annotations as the
parameters in the base class method.
The override method must have the same return type as the base class method.
134
Object-Oriented Programming in ActionScript
variable's access control specifier to
str
// error if str is not public
or
var
keyword indicates the programmer's intent to prevent
final
private
keyword and must match the superclass version of the
override
keywords are inherited, but cannot be
const
"Overriding getters and setters"
keyword in the base class. When used
final
access control specifier in the base
private
in the base class, there is no need to use the
,
private
protected
AccessControl
,

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents