Creating Inheritance In Actionscript 1.0 - MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

This step registers the symbol whose linkage identifier is
. All instances of
myClipClass
defined in step 4. They also behave the same as all instances of the MovieClip class
because you told the new class to inherit from the class MovieClip in step 3.
The complete code is shown in the following example:
function myClipClass(){}
myClipClass.prototype = new MovieClip();
myClipClass.prototype.onLoad = function(){
trace("movie clip loaded");
}
myClipClass.prototype.onPress = function(){
trace("pressed");
}
myClipClass.prototype.onEnterFrame = function(){
trace("movie clip entered frame");
}
myClipClass.prototype.myfunction = function(){
trace("myfunction called");
}
Object.registerClass("myclipID",myClipClass);
this.attachMovie("myclipID","clipName",3);

Creating inheritance in ActionScript 1.0

Many Flash users can greatly benefit from using ActionScript 2.0, especially with
complex applications. For information on using ActionScript 2.0, see
"Classes," on page
Inheritance is a means of organizing, extending, and reusing functionality. Subclasses inherit
properties and methods from superclasses, and add their own specialized properties and
methods. For example, reflecting the real world, Bike would be a superclass and
MountainBike and Tricycle would be subclasses of the superclass. Both subclasses contain, or
inherit, the methods and properties of the superclass (for example,
has its own properties and methods that extend the superclass (for example, the
MountainBike subclass would have a
and
to create inheritance in ActionScript.
__proto__
798
Object-Oriented Programming with ActionScript 1.0
myClipClass
225.
property). You can use the elements
gears
with the class
theID
have event handler methods that behave as
wheels
Chapter 7,
). Each subclass also
prototype

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents