如何找到一个关联数组的长度在ActionScript 3.0?数组、长度、ActionScript

2023-09-08 12:25:49 作者:颓废灬小猪

有没有来检索关联数组在ActionScript 3.0(实现为对象)的长度,一个简单的方法?

Is there a simple way to retrieve the length of an associative array (implemented as an Object) in ActionScript 3.0?

据我所知,在AS3创建关联数组的两种主要方式:

I understand that there are two primary ways of creating associative arrays in AS3:

使用一个词典对象;尤其方便的时候关键并不需要是一个字符串 使用的对象,并简单地为每一个需要的元素属性。属性名称是关键,和值,好了,值。 Use a Dictionary object; especially handy when the key does not need to be a string Use an Object, and simply create properties for each desired element. The property name is the key, and the value is, well, the value.

我的应用程序使用方法#2(使用对象类重新present关联数组)。

My application uses approach #2 (using the Object class to represent associative arrays).

我希望有一些东西比我的循环,人工计数的所有元素更原始。

I am hoping there is something more native than my for loop, which manually counts up all the elements.

推荐答案

您必须指望他们在一个for循环,你做的。当然,你可以做一个类,并坚持在for循环中的类。

You have to count them in a for loop as you do. Of course, you could make a class and stick the for loop in that class.

有关的集合在AS3中一些大implmentations,检查这些家伙。

For some great implmentations of Collections in AS3, check these guys.

修改2013 毫不奇怪,链接不要时间之后打破。试试这个新: http://www.grindheadgames.com/get-该长度的-的对象。

Edit 2013 Not surprisingly, links do break after time. Try this new one: http://www.grindheadgames.com/get-the-length-of-an-object.