0
有一個很好的例子Advanced Datagrid
和使用ArrayCollection
here。我喜歡有這樣的事情;如何創建ArrayCollection?
private var dpFlat:ArrayCollection = new ArrayCollection([
{Region:"Southwest", Territory:"Arizona",
Territory_Rep:"Barbara Jennings", Actual:38865, Estimate:40000},
{Region:"Southwest", Territory:"Arizona",
Territory_Rep:"Dana Binn", Actual:29885, Estimate:30000},
{Region:"Southwest", Territory:"Central California",
Territory_Rep:"Joe Smith", Actual:29134, Estimate:30000},
{Region:"Southwest", Territory:"Nevada",
Territory_Rep:"Bethany Pittman", Actual:52888, Estimate:45000},
{Region:"Southwest", Territory:"Northern California",
Territory_Rep:"Lauren Ipsum", Actual:38805, Estimate:40000},
{Region:"Southwest", Territory:"Northern California",
Territory_Rep:"T.R. Smith", Actual:55498, Estimate:40000},
{Region:"Southwest", Territory:"Southern California",
Territory_Rep:"Alice Treu", Actual:44985, Estimate:45000},
{Region:"Southwest", Territory:"Southern California",
Territory_Rep:"Jane Grove", Actual:44913, Estimate:45000}
]);
我需要讀取一個XML文件並從中獲取一些屬性。然後用這些屬性創建一個自定義ArrayCollection
。現在我正在創建一個自定義XML
,但我不想再使用XML
,而是選中Array Collection。
這裏是我讀的代碼,並創建另一個XML
;
kitapKonuSayisi = _tempXMLOR.Body.Ogrenci.length();
for(var itra:int = 0; itra < kitapKonuSayisi; itra++)
{
uniteAdi = _tempXMLOR.Body.Ogrenci[itra].UniteAdi;
konuAdi = _tempXMLOR.Body.Ogrenci[itra].KonuAdi;
ogrenciAyrintiRaporArray.push([uniteAdi, konuAdi]);
}
for(var itrc:int = 0; itrc < kitapKonuSayisi; itrc++)
{
kitapUniteSayisi = _tempXMLOR.Body.Ogrenci[itrc].UniteAdi.length();
uniteAdi = _tempXMLOR.Body.Ogrenci[itrc].UniteAdi;
if(raporStringUnitCheck === true)
{
ogrenciAyrintiRaporStr += ('\t<Unite name="' + uniteAdi + '" yuzde="' + 100 + '">\n');
raporStringUnitCheck = false;
}
for(var itrd:int = 0; itrd < kitapUniteSayisi; itrd++)
{
if(ogrenciAyrintiRaporArray[itrd][0] == _tempXMLOR.Body.Ogrenci[itrc].UniteAdi)
{
konuAdi = _tempXMLOR.Body.Ogrenci[itrc].KonuAdi;
ogrenciAyrintiRaporStr += ('\t\t<Konu name="' + konuAdi + '" yuzde="' + 100 + '"/>\n');
}
}
}
if(raporStringUnitCheck === false && raporStringCompCheck === false)
{
ogrenciAyrintiRaporStr += ('\t</Unite>\n');
ogrenciAyrintiRaporStr += ('</Rapor>');
raporStringCompCheck = true;
raporString2XML = new XML(ogrenciAyrintiRaporStr);
}
那麼如何才能創建ArrayCollection
和填充在該方案中的元素?