The idea behind parallel arrays is to create two (or more) arrays in which the elements with the same indices are related.
package{
import flash.display.Sprite;
public class Main extends Sprite{
public function Main(){
var aEmployeeNames:Array = ["A", "P", "C", "H"];
var aEmployeePhone:Array = ["555-1234", "555-4321", "555-5678", "555-8765"];
for(var i:Number = 0; i < aEmployeeNames.length; i++) {
trace("Employee:" + aEmployeeNames[i]);
trace("Phone Number:" + aEmployeePhone[i]);
}
}
}
}
Employee:A
Phone Number:555-1234
Employee:P
Phone Number:555-4321
Employee:C
Phone Number:555-5678
Employee:H
Phone Number:555-8765
Related examples in the same category