The coordinates also being swapped is logical since the only thing swapped are the movieclip references when it's an array of movieclips.
If you only want to swap some things, you could try something like this ...Another option of course is to change the function to swap everything except the properties you specify.Code:Array.prototype.objectSwap = function(i0, i1, props){ var i,p,t; props = props.split(','); t = new Object(); for (i = 0; i < this.length; i++){ p = props[i]; t[p] = this[i0][p]; this[i0][p] = this[i1][p]; } for (i = 0; i < this.length; i++){ p = props[i]; this[i1][p] = t[p]; } } a = [{x:1,y:2,z:7},{x:3,y:4,z:8},{x:5,y:6,z:9}]; // swap properties x and z of item 0 with x and z of item 2 a.objectSwap(0,2,'x,z'); txt1.text = 'x:' + a[0].x + ' y:' + a[0].y + ' z:' + a[0].z;




Reply With Quote