MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT Reference Manual page 803

Actionscript reference guide
Hide thumbs Also See for FLASH MX 2004 - ACTIONSCRIPT:
Table of Contents

Advertisement

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);
_root.attachMovie("myclipID","ablue2",3);
Creating inheritance in ActionScript 1
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,
methods that extend the superclass (for example, the MountainBike subclass would have a
property). You can use the elements
ActionScript.
All constructor functions have a
function is defined. The
created with that function. You can use the
to a class. (For more information, see
on page
801.)
All instances of a class have a
When you use a constructor function to create an object, the
the
property of its constructor function.
prototype
Inheritance proceeds according to a definite hierarchy. When you call an object's property or
method, ActionScript looks at the object to see if such an element exists. If it doesn't exist,
ActionScript looks at the object's
(
myObject.__proto__
ActionScript looks at
The following example defines the constructor function
function Bike (length, color) {
this.length = length;
this.color = color;
}
The following code adds the
Bike.prototype.roll = function() {this._x = _x + 20;};
wheels
prototype
prototype
property indicates the default property values for objects
prototype
prototype
"Assigning methods to a custom object in ActionScript 1"
property that tells you what object they inherit from.
__proto__
__proto__
). If the property is not a property of the object's
myObject.__proto__.__proto__
method to the Bike class:
roll()
). Each subclass also has its own properties and
and
to create inheritance in
__proto__
property that is created automatically when the
property to assign properties and methods
__proto__
property for the information
, and so on.
:
Bike()
gears
property is set to refer to
object,
__proto__
About ActionScript 1
803

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004 - ACTIONSCRIPT and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Table of Contents