[AS 3.0] for each..in 문법

ActionScript 3.0 — Tags: , — Siaa @ 10:25 am

for each..in 를 사용하면 오브젝트, XML, 배열의 모든 요소(값)에 대해서 반복처리를 할 수 있다.

//오브젝트의 반복 처리를 실행

var myObj:Object = {x:20, y:30};
for each (var num in myObj) {
 trace (num);
}

//출력 :
// 20
// 30

//XML 또는 XMLList 오브젝트의 반복 처리를 실행. 

var myXML:XML =
Jane
Susan
John
;
for each (var item in myXML.fname) {
 trace(item);
}

//출력
//Jane
//Susan
//John
//배열의 엘리먼트의 반복 처리를 실행할 수도 있음.

var myArray:Array = ["one", "two", "three"];
for each (var item in myArray) {
 trace (item);
}

//출력 :
// one
// two
// three
  • Share/Bookmark

0 Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2010 blog.flasia.com | powered by WordPress with Barecity