是否有可能在ArrayCollection中獲取物品的深度?ArrayCollection中物品的深度
回答
這裏是我的代碼...
public function getItemNestLevel(needle:Object, haystack:Object, level:Number = 0):Number
{
//iterate through items
for each (var item:Object in haystack)
{
if (item == needle)
{
return level;
}
//iterate through item's properties
for each (var child:Object in item)
{
if (child is Array || child is ArrayCollection)
{
var lvl:Number = level + 1;
var num:Number = getItemNestLevel(needle, child, lvl);
if (num >= 0)
{
return num;
}
}
}
}
return -1;
}
從livedocs:
// Get the index of the item with the value ME.
var addedItemIndex:int=myAC.getItemIndex("ME");
不是一個答案,我不能發表評論。
從活文檔:http://livedocs.adobe.com/flex/3/langref/mx/collections/ArrayCollection.html
ArrayCollection類是一個包裝 類暴露數組作爲 集合,可以訪問和 使用方法及的ICollectionView的或 的IList的 特性操縱接口。
爲什麼你認爲ArrayCollection具有深度?
我想你可以做一個ArrayCollection子ArrayCollections。如果是這樣的話;那麼你可以編寫一個函數來搜索其所有子ArrayCollections。
編輯:我認爲你建議的功能有一些錯誤。這裏有一個功能我想:
public function getItemNestLevel2(needle:Object, haystack:Object):Number
{
for each (var item:Object in haystack)
{
if (item == needle)
return 0;
if (item is Array || item is ArrayCollection)
{
var nestLevel:int = getItemNestLevel2(needle, item);
if (nestLevel >= 0)
return nestLevel + 1;
}
}
return -1;
}
我希望,已經有這樣的功能。謝謝 – luccio 2010-03-22 08:16:03
對於Flex的批評我聽說過, Flex沒有很棒的收藏類。 : - / – 2010-03-22 11:10:58
- 1. 從ArrayCollection中檢索對象物品信息?
- 2. 在C#中深度克隆深物體(很深)
- 3. 不同物體之間的深度
- 4. AS3 - 改變物體在所述物體內的深度
- 5. 物品標籤的動態高度
- 6. 用flexbox增加物品的高度
- 7. 相同高度的Flexbox centeres物品
- 8. 具有多個物品高度的RecyclerView
- 9. 獲取js物品的物品數量
- 10. 如何在物品移動的同時動態顯示物品透明度
- 11. Flex:另一個ArrayCollection中的arrayCollection?
- 12. PHP中的ArrayCollection
- 13. Plist中物品的順序
- 14. 展車中的物品
- 15. Android Studio:列出物品(物品)
- 16. 讓WPF Tabcontrol高度假定最大物品的高度?
- 17. 深度
- 18. 深度
- 19. 使用深度信息的物體識別算法的建議
- 20. 嵌套js對象中物品的計數長度
- 21. flexbox中的統一自動物品高度
- 22. 如何知道matlab中24位深度圖像的深度值
- 23. SQL中的樹深度
- 24. .NET中的深度反射
- 25. Yui3中的深度克隆
- 26. Actionscript中的深度克隆
- 27. 在Magento中使用一種物品作爲多個物品
- 28. 如何從一組物品中選擇特定物品?
- 29. 像素深度與顏色深度
- 30. 深度優先搜索確定深度
它不深,但指數...由「深度」我的意思是多少嵌套在ArrayCollection,其中項目樹 – luccio 2010-03-21 16:45:37