Array « Actionscript Programming « Flash Tutorials

Home
Flash Tutorials
1.Actionscript Programming
2.Animals
3.Animation
4.Colors
5.Design
6.Effects
7.Game Cartoon
8.Humans
9.Models
10.Nature
11.Operations
12.Shapes
Photoshop Tutorials
Maya Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
Flash Tutorials » Actionscript Programming » Array 
Not that this is more complex then the first, one dimensional array, but its worth while digging into, so if you think your ready, lets get started.

Hello and welcome. Today we shall be leaning about one concept of Flash, arrays. Arrays are used for storing groups of information.Essentially, an array is a list of items. Those items can be text, or numbers, or decimals, or anything. Arrays in Flash ( like lists) start with bit-of-info number 0.

Flash on the beach 2009 - Day 1

Flash on the beach 2009 - Day 1

Flash on the beach 2009 - Day 1

var myChest = new Array("cup","ball","hat","gloves","pen"); for(var i=0;i<=myChest.length-1;i++){ trace(myChest[i]); } // display the strings cup, ball, hat, gloves and pen in the output window

Here is a more detailed form of our array:

There are a few things that are interesting about the results. Notice that Tests 2 and 3 both return a 1, but 10 is a number in Test 2 but a string value in Test 3. The reason for that is because our contains function does not do type-checking. Our == operator in the for loop doesn't differentiate between a number and a string of the same number.

// Credits: FlashGuru Array.prototype.copy=Array.prototype.slice; // test tester=[1,2,3,4]; tester2=tester.copy(); tester.pop(); trace (tester2);

The following lines are of peculiar interest to us though:

This tutorial will hold a basic introduction on three main points regarding arrays: (1) the creation of arrays, (2) accessing arrays, and finally (3) modifying arrays. This tutorial does not claim to tell you everything about arrays, but it will give you the required knowledge for you to start your own exploration on arrays in ActionScript.

An Array is just a computer term for a: List. Arrays are extremely useful in Flash, and there are numerous uses for Arrays in other programs. The aim of this tutorial is to learn how to use Arrays. There are four examples in this tutorial that show you how to use Arrays in slightly different ways. This tutorial goes through all of them in detail, explaining all the ActionScript.

w_w__w___._ja__va__2_s.c___o___m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.