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());

This entry was posted in Actionscript 3.0 and tagged . Bookmark the permalink.

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

  1. Bruno says:

    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 *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>