是否有可能在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