798
Object-Oriented Programming with ActionScript 1.0
This step registers the symbol whose linkage identifier is
theID
with the class
myClipClass
. All instances of
myClipClass
have event handler methods that behave as
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
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,
wheels
). Each subclass also
has its own properties and methods that extend the superclass (for example, the
MountainBike subclass would have a
gears
property). You can use the elements
prototype
and
__proto__
to create inheritance in ActionScript.
NO
T
E
Many Flash users can greatly benefit from using ActionScript 2.0, especially with
complex applications. For information on using ActionScript 2.0, see
Chapter 7,
“Classes,” on page 225
.
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...