Flash / Flex / ActionScript/Array/split — различия между версиями

Материал из Web эксперт
Перейти к: навигация, поиск
м (1 версия)
 
м (1 версия)
 
(нет различий)

Текущая версия на 11:14, 26 мая 2010

Converting a String to an Array: Use the String.split(delimiter, maximum_number_of_elements_to_place_into_the_new_array) method.

   <source lang="java">

package{

 import flash.display.Sprite;
 
 public class Main extends Sprite{
   public function Main(){
       var list:String = "Piper picked a peck of pickled peppers";
       var words:Array = list.split(" ");
       
       trace(words);
   }
 }

}

       </source>
   
  


The split() method asks that you specify the delimiter it should use to determine the elements of the list

   <source lang="java">

package{

 import flash.display.Sprite;
 
 public class Main extends Sprite{
   public function Main(){
       var sEmployees:String = "A,P,C,H";
       var aEmployees:Array = sEmployees.split(",");
       trace(aEmployees); 
   }
 }

}

       </source>