Actionscript 3: Move first array index to the back and back to front

Here is a very cool line of code to manipulate an array.

If you want to take the first item of an array and place it at the end:

myArray.push(myArray.shift());

If you want to take the last item of an array and place it back at the front:

myArray.unshift(myArray.pop());

[ad#Google Adsense]

Author: mark

Creative technologist

One thought on “Actionscript 3: Move first array index to the back and back to front”

  1. Brilliantly simple!! Thanks a lot, you probably saved me some hours of headache… 🙂

    have a nice week!

Leave a Reply

Your email address will not be published. Required fields are marked *