/ Published in: ActionScript 3
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function putLastItemOfArrayAtBeginning($a:Array):Array { $a.unshift($a[$a.length-1]); $a.pop(); return $a; } var myArray:Array = new Array(0,1,2,3,4,5); trace(myArray); myArray = putLastItemOfArrayAtBeginning(myArray); trace(myArray); myArray = putLastItemOfArrayAtBeginning(myArray); trace(myArray); myArray = putLastItemOfArrayAtBeginning(myArray); trace(myArray); // OUTPUT: 0,1,2,3,4,5 // OUTPUT: 5,0,1,2,3,4 // OUTPUT: 4,5,0,1,2,3 // OUTPUT: 3,4,5,0,1,2