/** *@author Michael Bianco, http://developer.mabwebdesign.com/ *@description prototypes for the Object root class *@version 1.1 **/ import mx.events.EventDispatcher; /** *@description: inits the object as a EventDispatcher object if it already hasn't been inited **/ Object.prototype.initBroadcaster = function() { if(!this.__initedBroadcaster) { mx.events.EventDispatcher.initialize(this); this.__initedBroadcaster = true; } } /** *@description: tests whether the object is a member of the param classref *@param: classRef, a reference to a class object. IE Number *@returns: bool, representing if the object belongs to the specified class or not **/ Object.prototype.isInstanceOf = function(classRef) { if(this.__proto__ == classRef.prototype) { return true; } else { return false; } } /** *@description: tests whether the object is a descendant/member of the param classref *@param: classRef, a reference to a class object. IE Number *@returns: bool, representing if the object belongs or descends from the specified class or not **/ Object.prototype.isMemberOf = function(classRef) { if(classRef == Object) {//always a descendant of an object! return true; } var ref = this.__proto__; while(ref != classRef.prototype) { ref = ref.__proto__; if(ref == Object.prototype) { return false; } } return true; } /** *@description: centers the object horizontally depending on the given max x value *@param: xval, the max x position that the mc could be **/ Object.prototype.centerX = function(xval) { this._x = Math.round((xval-this._width)/2); } /** *@description: centers the object vertically depending on the given max y value *@param: yval, the max y position that the mc could be **/ Object.prototype.centerY = function(yval) { this._y = Math.round((yval-this._height)/2); } /** *@description: centers the object vertically and horizontally depending on the given max x and y value's *@param: yval, the max y position that the mc could be *@param: xval, the max x position that the mc could be **/ Object.prototype.centerXY = function(x, y) { this.centerX(x); this.centerY(y); }