How to Use Arrays in Adobe Flash
Create an array., Add items to your array., Access array items., Push items into an array., Understand how to remove the last item from your array you use the method pop., Merge two arrays, note this will merge array2 items after array1 items to...
Step-by-Step Guide
-
Step 1: Create an array.
Arrays are like any other variable need to be initialised.
There are some subtle differences between different versions of ActionScript so please check the version you are targeting. -
Step 2: Add items to your array.
Once you have initialised your array you will want to add some items to it.
As this is a collection of items you need to add a number to your array to specifically pick the item to access Like in other languages you append square brackets with a number in side them. , To use the items you just added to your array just call the array name with the index of the item you want to access. , Push is another way of saying add items to your array each item will be added to the end of your array.
You can push one item at a time or multiple items.
To "Push" and item or items in you your array at the beginning the method unshift is used.
The shift method is explained below. , To remove the item at the beginning of your array you use the method shift. ,, At some point, you may want to reverse the order of the items in your array.
This is done by using the method reverse. -
Step 3: Access array items.
-
Step 4: Push items into an array.
-
Step 5: Understand how to remove the last item from your array you use the method pop.
-
Step 6: Merge two arrays
-
Step 7: note this will merge array2 items after array1 items to reverse this swap array1 and array2.
-
Step 8: Know how to reverse the orders of the item in the array.
Detailed Guide
Arrays are like any other variable need to be initialised.
There are some subtle differences between different versions of ActionScript so please check the version you are targeting.
Once you have initialised your array you will want to add some items to it.
As this is a collection of items you need to add a number to your array to specifically pick the item to access Like in other languages you append square brackets with a number in side them. , To use the items you just added to your array just call the array name with the index of the item you want to access. , Push is another way of saying add items to your array each item will be added to the end of your array.
You can push one item at a time or multiple items.
To "Push" and item or items in you your array at the beginning the method unshift is used.
The shift method is explained below. , To remove the item at the beginning of your array you use the method shift. ,, At some point, you may want to reverse the order of the items in your array.
This is done by using the method reverse.
About the Author
Scott Chapman
Writer and educator with a focus on practical crafts knowledge.
Rate This Guide
How helpful was this guide? Click to rate: