Storing Complex or Multidimensional Data : Array Dimension « Array « Flash / Flex / ActionScript






Storing Complex or Multidimensional Data

 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){


        var colors:Array = ["red", "blue",    "blue",     "gray"];
        var years:Array  = [1997,     2000,       1985,       1983];
        var makes:Array  = ["H",  "C", "M", "F"];
             
        for (var i:int = 0; i < makes.length; i++) {
            trace("A " + colors[i] + " " + 
                         years[i] + " " + 
                         makes[i]);
        }
    }
  }
}
A red 1997 H
A blue 2000 C
A blue 1985 M
A gray 1983 F

        








Related examples in the same category

1.Working with Single-Dimension Arrays
2.Multidimensional Arrays
3.Create a single array in which each element is a string containing both pieces of data, separated by a delimiter such as a colon (:)
4.The idea behind parallel arrays is to create two (or more) arrays in which the elements with the same indices are related.
5.Working with Multidimensional Arrays
6.With multidimensional arrays, concat( ) or slice( ) only duplicates the top level of the array
7.Working with multiple sets of data: create a multidimensional array
8.Use nested for loop to deal with multiple sets of data
9.You can specify the properties of the object in any order you like
10.Creating an Associative Array
11.Create an associative array by adding properties to object
12.Compose dynamic properties
13.Two ways to add properties to dynamic object
14.Reading Elements of an Associative Array