请大家帮帮忙,翻译一下,谢谢,要具体的var users_ds:mx.data.components.DataSet;//users_ds.addItem({name:"Irving",age:34});users_ds.addItem({name:"Christopher",age:48});users_ds.addItem({name:"Walter",age:23});//users_ds.first();while(users_ds.hasNext()){ trace("name:"+users_ds.currentItem["name"]+",age:"+users_ds.currentItem["age"]); users_ds.next();}
没人回答,我帮你解释://定义DataSet,这是一个as2.0组件var users_ds:mx.data.components.DataSet;//对组件,添加数据集。{}是对象运算符users_ds.addItem({name:"Irving",age:34});users_ds.addItem({name:"Christopher",age:48});users_ds.addItem({name:"Walter",age:23});//使集合当前视图中的第一个项目成为当前项目,相当于把指针指向第一个数据,为下面的遍历数据做准备。users_ds.first();//遍历数据,并trace()出数据,hasNext()判断数据是否结束,next()指针向下一个while(users_ds.hasNext()){ trace("name:"+users_ds.currentItem["name"]+",age:"+users_ds.currentItem["age"]); users_ds.next();} //这个同样可以用forin循环代替。象这样:for (var i in users_ds.items){ trace("name:"+users_ds.currentItem["name"]+",age:"+users_ds.currentItem["age"]); users_ds.next(); }