将数组添加到datagrid时出错

时间:2012-05-30 07:50:22

标签: actionscript-3

您好我的项目中有一个数据网格,我有以下错误:

warning: unable to bind to property 'name' on class 'Array' (class is not an IEventDispatcher)

这是我分配数据的地方:

var myarr:Array = [];
packageData = packageData=SharedObject.getLocal("local_data");
for (var packageId:String in packageData.data.packages) {
    myarr.push(packageData.data.packages[packageId])
}

cur_uploads = new ArrayCollection(myarr);
dg_uploads.dataProvider = cur_uploads;

我读过我应该使用proxyObject,但我无法将Array转换为Object。那么还有其他解决方案可以摆脱错误吗?

1 个答案:

答案 0 :(得分:0)

以下是我的工作:

   var arrayCollection:ArrayCollection = new ArrayCollection();
   packageData = SharedObject.getLocal("local_data");

   for (var packageId:String in packageData.data.packages) {
       arrayCollection.addItem(new ObjectProxy(
            packageData.data.packages[packageId]
       ));
   }

   dg_uploads.dataProvider = arrayCollection;