我有一个2D数组,如下所示:
Asia India Chennai TN Category1 Product1 100
Asia India Mumbai MH Category1 Product1 100
Asia India Calcutta CT Category1 Product1 100
Asia India Calcutta CT Category2 Product2 200
EMEA UK London LN Category3 Product1 123
EMEA UK London LN Category3 Product2 455
EMEA UK Reading RN Category1 Product1 500
EMEA UK Reading RN Category1 Product2 430
我如何将上述2D数组转换为数组集合,以便我可以访问具有单个属性的每个数据,例如第一列指示属性为"大陆",第二列为"国家"等,arrayCollection具有结构为{continent:"Asia", country:"India",…等等。如何动态实现
private var a:Array=new Array([100,200,300,40],[252,25,25,32]);
private var a1:Array=new Array();
[Bindable]
private var ac:ArrayCollection=new ArrayCollection();
private function init():void
{
for(var i:int=0;i<a.length;i++)
{
a1[i]=new Array()
for(var j:int=0;j<a[i].length;j++)
{
a1[i]["col"+j]=a[i][j];
}
}
ac.source=a1;
ac.refresh()
Alert.show(ac.toString());
}