Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 142

Programming actionscript 3.0
Table of Contents

Advertisement

ActionScript 2.0
ActionScript 2.0 introduced new keywords such as
that allowed you to define classes in a way that is familiar to anyone who works with class-
based languages like Java and C++. It's important to understand that the underlying
inheritance mechanism did not change between ActionScript 1.0 and ActionScript 2.0.
ActionScript 2.0 merely added a new syntax for defining classes. The prototype chain works
the same way in both versions of the language.
The new syntax introduced by ActionScript 2.0, shown in the following excerpt, allows you to
define classes in a way that many programmers find more intuitive:
// base class
class Shape
{
var visible:Boolean = true;
}
Note that ActionScript 2.0 also introduced type annotations for use with compile-time type
checking. This allows you to declare that the
should contain only a Boolean value. The new
creating a subclass. In the following example, the two-step process necessary in ActionScript
1.0 is accomplished in one step with the
// child class
class Circle extends Shape
{
var id:Number;
var radius:Number;
function Circle(id, radius)
{
this.id = id;
this.radius = radius;
}
}
The constructor is now declared as part of the class definition, and the class properties
must also be declared explicitly.
radius
ActionScript 2.0 also added support for the definition of interfaces, which allow you to
further refine your object-oriented programs with formally defined protocols for interobject
communication.
142
Object-Oriented Programming in ActionScript
,
class
extends
property in the previous example
visible
keyword also simplifies the process of
extends
keyword:
extends
,
, and
public
private
id
,
and

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents