是否有可能在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. 物體的深度和深度知覺
- 2. Joomla - 限制特定物品的菜單深度?
- 3. 從ArrayCollection中檢索對象物品信息?
- 4. 在C#中深度克隆深物體(很深)
- 5. 如何減少物品清單物品的高度?
- 6. 不同物體之間的深度
- 7. jcarousel 100%li物品寬度?
- 8. AS3 - 改變物體在所述物體內的深度
- 9. 速度更換的物品的財產
- 10. 的Android的ListView丟失物品高度
- 11. 的Sql - 使所有物品的長度
- 12. 獲取REST中的物品清單時找不到的物品找到物品
- 13. TortoiseSVN - 如何在自定義深度檢出結帳額外物品
- 14. 收集物品的最快速度收集,每個物品都有要迭代的物品集合
- 15. 物品標籤的動態高度
- 16. 用flexbox增加物品的高度
- 17. 相同高度的Flexbox centeres物品
- 18. 具有多個物品高度的RecyclerView
- 19. 獲取js物品的物品數量
- 20. opencv中物體左側的黑色邊框SGBM深度圖
- 21. 如何在物品移動的同時動態顯示物品透明度
- 22. Flex:另一個ArrayCollection中的arrayCollection?
- 23. PHP中的ArrayCollection
- 24. 展車中的物品
- 25. 堆中最大的物品
- 26. Plist中物品的順序
- 27. Android Studio:列出物品(物品)
- 28. 深度網絡如何接受物體檢測中不同尺度的圖像?
- 29. 試圖從兩級深度關聯中找到物品的計數,有什麼想法?
- 30. CALayer的深度
它不深,但指數...由「深度」我的意思是多少嵌套在ArrayCollection,其中項目樹 – luccio 2010-03-21 16:45:37