flex中 for in 与 for each in 的区别。
?
package { import flash.display.Sprite;public class firstActionScript extends Sprite { //flex工作原理 浏览器嵌入的flash player 运行flex生产的html html运行生产的swf// * 任意的数据类型public function firstActionScript(){var array:Array = ["a","b","c","d"];for(var str:String in array) {trace("str"+str); //拿到的是索引 0 1 2 3trace(array[str]);//拿到的值 a b c d}for each(var str1:String in array) {trace("str"+str1);//直接拿值 a b c d}trace("------------------------------");var obj:Object = {id:3,name:"zhangsan",age:18};trace(obj.id);trace("--------------");for (var st:String in obj) {trace(st);//拿到属性 id name age}for each(var st1:String in obj) {trace(st1);//拿到属性对应的值 3 zhangsan 18}trace("--------------");trace(obj.name); //结果zhangsantrace(obj["name"]);//结果zhangsan} } }?
?