arraysactionscript-3flashactionscript

AS3 CHANGING the order of an Array - eliminate zero?


I have an array of 10 items.

var myArray:Array = ["One", "Two", "Three","Four", "Five", "Six","Seven", "Eight", "Nine","Ten"];

I would like to keep these same ten items but want the array to start with 1 and not 0.

For example if I called.

trace(myArray[1]); // this should display "One";

if did this...

trace(myArray[7]); // this should display "Seven";

What SIMPLE function could I write to change this order?


Solution

  • Add "Zero" as the first element of that array. Should do :)