User Guide
Advanced topics 139
public function Extender()
{
trace(test); // output: instance
}
}
Advanced topics
This section begins with a brief history of ActionScript and OOP and continues with a
discussion of the ActionScript 3.0 object model and how it enables the new ActionScript
Virtual Machine (AVM2) to perform significantly faster than previous versions of Flash Player
that contain the old ActionScript Virtual Machine (AVM1).
History of ActionScript OOP support
Because ActionScript 3.0 builds upon previous versions of ActionScript, it may be helpful to
understand how the ActionScript object model has evolved. ActionScript began as a simple
scripting mechanism for early versions of the Flash authoring tool. Subsequently,
programmers began building increasingly complex applications with ActionScript. In
response to the needs of such programmers, each subsequent release has added language
features that facilitate the creation of complex applications.
ActionScript 1.0
ActionScript 1.0 refers to the version of the language used in Flash Player 6 and earlier. Even
at this early stage of development, the ActionScript object model was based on the concept of
the object as a fundamental data type. An ActionScript object is a compound data type with a
group of properties. When discussing the object model, the term properties includes everything
that is attached to an object, such as variables, functions or methods.
Although this first generation of ActionScript does not support the definition of classes with a
class keyword, you can define a class using a special kind of object called a prototype object.
Instead of using a
class keyword to create an abstract class definition that you instantiate
into concrete objects, as you do in class-based languages like Java and C++, prototype-based
languages like ActionScript 1.0 use an existing object as a model (or prototype) for other
objects. While objects in a class-based language may point to a class that serves as its template,
objects in a prototype-based language point instead to another object, its prototype, that
serves as its template.