
Added by roScripts on August-25-2007, 2:48 pm
/*
************************************************************
Developed by R.Arul Kumaran [arul@shockwave-india.com] *
for more code keep visiting [www.shockwave-india.com/blog] *
************************************************************
*/
/*
Object.Clone creates a perfect copy of an object
Modified from FlashGuru's version to support Arrays
*/
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);
/*
Usage:-
myObject=new Object()
myObject.name="Arul";
myObject.gender="Male";
myObject.age=29;
copyObject=myObject.clone();
//now copyObject containes {name:"Arul", gender:"Male", age:29};
//changing myObject will not affect copyObject
*/
Added by roScripts on March-26-2008, 5:14 pm
Added by roScripts on March-26-2008, 5:13 pm
Added by roScripts on March-26-2008, 5:09 pm
Added by roScripts on March-26-2008, 5:08 pm
Added by roScripts on March-26-2008, 5:07 pm
