Introduction

Flash is a lightweight cross-platform runtime for rich media, enterprise applications and mobile applications, as well as an integrated development environment. Flash can be programmed in ActionScript 1/2/3.

Monday, July 7th, 2003 at 1:56 pm

Multiple Inheritance

I needed a multiple inheritance script for one of my projects and I thought maybe it would be helpful for other’s too. It also enables you to edit the prototype chain during runtime. So here is the code:

o = _global.MultipleInheritance=function () {}
o.initialize = function(obj) {
        if(obj.classes == undefined) obj.classes = new Object();
        obj.__resolve = this.__resolve;
        obj.addClass = this.addClass;
        obj.removeClass = this.removeClass;
        return obj;
}
o.__resolve = function() {
        for (var i in this.classes) {
                var f = this.classes[i].prototype[arguments];
                if(f != undefined) return f;
        }
}
o.addClass = function() {
        if(arguments.length>1){
                for(var i in arguments){
                        this.classes[arguments[i]] = eval(arguments[i]);
                }
        } else {
                this.classes[arguments] = eval(arguments);
        }
}
o.removeClass = function() {
        if(arguments.length>1){
                for(var i in arguments){
                        delete this.classes[arguments[i]];
                }
        } else {
                delete this.classes[arguments];
        }
}
delete o;

// example
SuperClass1 = function () {}
SuperClass2 = function () {}

// 1
SubClass = function () {}
MultipleInheritance.initialize(SubClass.prototype);
SubClass.prototype.addClass(”SuperClass1“, “SuperClass2“);

// 2
this.createEmptyMovieClip(”mc“, 1);
MultipleInheritance.initialize(this.mc);
this.mc.addClass(”SuperClass1“, “SuperClass2“);

One Response to “Multiple Inheritance”

  1. Andre Michelle

    Works fine for me.
    So sad, that the methods of the SuperClasses cannot be named equal. But this is the non private function madness in flash :o)

order generic viagra accutane online find cheap viagra buy generic soma price of clomid cialis online cheap viagra drug drug cialis buying generic viagra pharmacy cialis buy cheapest viagra purchase soma viagra cost order cialis viagra for sale buy cialis purchase synthroid online generic zithromax viagra overnight shipping cheapest viagra online cheapest zithromax cheap cialis tablet buy viagra from india acomplia prescription buy viagra no prescription required levitra pharmacy buying generic cialis buy zithromax without prescription lasix online viagra buy online zithromax without a prescription buy cialis from canada purchase viagra overnight delivery cialis for sale levitra online stores buy acomplia without prescription cheap generic levitra cheap propecia online cheap price viagra buy cheap viagra internet synthroid pharmacy viagra online cheap cialis uk cheap viagra from uk cheapest generic cialis online buy cialis in canada accutane pharmacy find cialis no prescription required order acomplia cheapest propecia price of acomplia buy generic cialis viagra in bangkok buy cheap propecia online buy lasix purchase levitra online find cheap viagra online buy discount viagra online clomid pharmacy clomid without a prescription buy generic acomplia soma prices cheapest soma buy zithromax lasix prescription viagra discount levitra without a prescription buy zithromax cheap acomplia pills cheap accutane cheap viagra overnight delivery soma buy viagra us