dankdank

Main News Games Art Favorites Reviews Stats 9 Fans
Add to Favorites
dank
Age / Gender:
18, Male
Location:
Bucks County, PA
Joined:
10/11/05
All Stats >

.dan kolbman

User Statshot

Community Stats
Level 22 Blank Slate
Normal Whistle
Ranked as Police Lieutenant

Contact Info / Websites

Latest News


Arrays make a great way to store and manage data in actionscript. However, sometimes just a single dimension may not be adequate for some situations such as when storing table data. Then you will need to either: define an array for each column for every row, or just make a one two-dimensional array.

A two-dimensional array can be thought of an array nested in an array. To instantiate an array, we can either do:

var arr1:Array = new Array(1, 2, 3);
var arr2:Array = new Array(4, 5, 6);
var arr3:Array = new Array(7, 8, 9);
var arr:Array = new Array(arr1, arr2, arr3);

Or the quicker way:

var arr:Array = new Array([1, 2, 3], [4, 5, 6], [7, 8, 9]);

All we're doing here is defining arrays inside of an array. To reference a two-dimensional array is practically the same as a normal array except for we have a second element to reference. This means we just need to add another "[n-1]:"

// Output: 6
trace(arr[1][2]);

To add a new element to the first array, we can use the same syntax as we would with a single-dimension array, but we would be pushing an array data type:

// Adds another element to the outer array
arr.push(arr1);

To add an element to one of our existing arrays, we reference the array's element in the outer array:

// Ads a sub element to arr1[1] (= 4,5,6)
arr[1].push(arr1);

The rest of the functions in the Array package are used in the same way, but with different references to the caller.


Recent Game Medals

There and Black Again 50 Points Watch Africa Dudes twice in a row, black to black! (Without re-loading your window!) Go to game.
There 25 Points Sit there, shut up, and watch the entire thing...ALL THE WAY TO THE BITTER END. Go to game.
Endeavor 5 Points Fall to the world below. Go to game.
Phase IV 50 Points Complete the final phase. Go to game.
Phase III 25 Points Complete the third phase. Go to game.
Phase II 10 Points Complete the second phase. Go to game.
Phase I 5 Points Complete the first phase. Go to game.
a223 5 Points a223 Go to game.
a168 5 Points a168 Go to game.
a164 5 Points a164 Go to game.


Total Medals Earned: 298 (From 33 different games.)