首页 > 代码库 > flex for循环

flex for循环

一:for

var i:int;for (i = 0; i < 5; i++){trace(i);}

二:for ...in

循环object:

var myObj:Object = {x:20, y:30};for (var i:String in myObj){trace(i + ": " + myObj[i]);}// output:// x: 20// y: 30

循环array:

var myArray:Array = ["one", "two", "three"];for (var i:String in myArray){trace(myArray[i]);}// output:// one// two// three

三、foreach...in

循环object:

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

循环array:

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

 

flex for循环