Create a single array in which each element is a string containing both pieces of data, separated by a delimiter such as a colon ( : Array Dimension : Array Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Array » Array Dimension »

 

Create a single array in which each element is a string containing both pieces of data, separated by a delimiter such as a colon (


 

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


        var aEmployees:Array = new Array();
        aEmployees.push("A:555-1234");
        aEmployees.push("P:555-4321");
        aEmployees.push("C:555-5678");
        aEmployees.push("H:555-8765");
        
        var aTempEmployeeInfo:Array = null;
        for(var i:Number = 0; i < aEmployees.length; i++) {
          aTempEmployeeInfo = aEmployees[i].split(":");
          trace("Employee:" + aTempEmployeeInfo[0]);
          trace("Phone Number:" + aTempEmployeeInfo[1]);
        }
    }
  }
}
Employee:A
Phone Number:555-1234
Employee:P
Phone Number:555-4321
Employee:C
Phone Number:555-5678
Employee:H
Phone Number:555-8765

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Array
» Array Dimension