Public feed #380848

Stuff

public text v1 · immutable
Raw Edit
·published 2007-03-04 12:33 UTC
rendered paste body

//--------------------------------------------------------------
Object.prototype.clone = function() {
	if (this instanceof Array) {
		var to = [];
		for (var i = 0; i<this.length; i++) {
			to[i] = (typeof (this[i]) == "object") ? this[i].clone() : this[i];
		}
	} else if (this instanceof XML || this instanceof MovieClip) {
		// can't clone this so return null
		var to = null;
		trace("Warning! Object.clone can not be used on MovieClip or XML objects");
	} else {
		var to = {};
		for (var i in this) {
			to[i] = (typeof (this[i]) == "object") ? this[i].clone() : this[i];
		}
	}
	return to;
};
ASSetPropFlags(Object.prototype, ["clone"], 1);