////////////////////////////////////////////////////////////////////////////////// // // OOP goodies for Flash MX // // Created by Timothee Groleau - 08/04/2003 // // For best use of the static properties, use cExtends // to do inheritance as follow: // // subClass.cExtends(superClass); // // ////////////////////////////////////////////////////////////////////////////////// Function.prototype.cExtends = function(SuperClass) { this.prototype.__proto__ = SuperClass.prototype; this.prototype.__constructor__ = SuperClass; this.__proto__ = SuperClass; } Function.prototype.addStaticProperty = function(name, prop) { var getter = function() { return prop; } var setter = function(val) { prop = val; } this.addProperty(name, getter, setter); this.prototype.addProperty(name, getter, setter); } Function.prototype.addStaticMethod = function(name, theFunc) { var _theClass = this; var getter = function() { return theFunc; }; var setter = function(meth) { theFunc = function() { return meth.apply(_theClass, arguments); }; }; setter(theFunc); this.addProperty(name, getter, setter); this.prototype.addProperty(name, getter, setter); } ASSetPropFlags(Function.prototype, "cExtends,addStaticProperty,addStaticMethod", 1); Object.prototype.addProperty2 = function(name, getter, setter) { var prop; this.addProperty(name, function() { return getter.call(this, prop); }, function(val) { prop = setter.call(this, val); } ); } Object.prototype.addPrivateProperty = function(name, getter, setter) { var prop; this["get" + name] = function() { return getter.call(this, prop); }; this["set" + name] = function(val) { prop = setter.call(this, val); }; } ASSetPropFlags(Object.prototype, "addProperty2,addPrivateProperty", 1);