我想要一个包含多个字符串的文本区域,将其值发送到数组,并将数组转换为对象。然后,对象填充数据网格。我无法确定从哪里开始:
var arrayString:String = myTextArea.text;
var newArray:Array = arrayString.split(",");
var n:int=newArray.length;
while (n--)
{
newArray[n]=Number(newArray[n])
var obj:Object = new Object();
obj.label = newArray[n];
this.myDataGrid.addItem(obj );
}
答案 0 :(得分:2)
var arrayString:String = myTextArea.text;
var newArray:Array = arrayString.split(",");
var n:int=newArray.length;
var dataProvider:ArrayCollection = new ArrayCollection;
while (n--)
{
newArray[n]=Number(newArray[n])
var obj:Object = { label: newArray[n] };
dataProvider.addItem(obj);
}
this.myDataGrid.dataProvider = dataProvider;