here i found a quite interesting method which is really useful when you need to swap two values in a array
======================================================================
var myArray:Array=["flash","flex","html","dhtml","javascript"];
Array.prototype.swap = function(fromIndex:int, toIndex:int):void {
var temp:* = this[toIndex];
this[toIndex] = this[fromIndex];
this[fromIndex] = temp;
}
;
//swaping first and second index of a array
myArray.swap(0,1);
for (var i :Number=0; i<myArray.length; i++) {
trace(myArray[i]);
}
======================================================================
var myArray:Array=["flash","flex","html","dhtml","javascript"];
Array.prototype.swap = function(fromIndex:int, toIndex:int):void {
var temp:* = this[toIndex];
this[toIndex] = this[fromIndex];
this[fromIndex] = temp;
}
;
//swaping first and second index of a array
myArray.swap(0,1);
for (var i :Number=0; i<myArray.length; i++) {
trace(myArray[i]);
}
Comments
Post a Comment