Introduction

You are currently browsing the weblog archives for July, 2003.

Archive for July, 2003

Wednesday, July 9th, 2003

Button Events for TextFields

Ich just read the book OOP with Actionscript from Branden Hall and Samuel Wan. They explain OOP with AS in a simple and not to long way so that everyone can understand it. It also offers I summery of tricks from advanced flash developers. But that isn’t part of that thread. I came across the part about textfields and thought it would be handy if you could just use a textfield like a button e.g. myTextField_txt.onRelease = function … . So I extended the TextField class a little bit. It also returns a path to the recently created textfield.
(more…)

Monday, July 7th, 2003

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“);