开发者

Is there any way to assign an index of my choice to array collection in flex?

开发者 https://www.devze.com 2023-01-30 06:20 出处:网络
I want to give an array index to array collection let say 205 when it is started is it possible to do so in flex or any alternate of this.

I want to give an array index to array collection let say 205 when it is started is it possible to do so in flex or any alternate of this.

actually I need to index the objects with a specific no, in 2D array collection

say

205 a c d g f d 
268 s g h g f f
805 d g h h f f d
开发者_Go百科

where integers are indexes and alphabets are object referenced by these integers


ArrayCollections are wrappers for Arrays (with more functionality + binding + all sorts of awesome [if one can use awesome as a noun]).

The Array class is not as "associative" as is the Dictionary class. So, you could either use a dictionary, which is probably what you're really looking for. Or you could extend ArrayCollection (which extends ListCollectionView which extends Proxy -- which was @BrianBenisio's suggestion). So it really depends on your project, what you want to accomplish, if you need binding, and how much time you have.

You gave the example by detailing a 2D collection:

205 a c d g f d 
268 s g h g f f
805 d g h h f f d

so I'm going to guess that you are dealing with a datasource that is xml based (or at least based on something similar to SimpleDB, with rows that don't have static columns). So if it were me, I'd stick with an Array and build an internal "ArrayUtils" class that acts as a means to your end. Though, if you're using the latest version of Flex, you may want to think about typing your array and going down the path of using the Vector class. With a customized typed vector, you'll find better performance and customizable functionality that you'd otherwise be missing.

Good luck in any case.

rock on, Jeremy


I am having some trouble completely understanding your question, but if I do understand you correctly, you want to override the indexing method of an object?

The easiest way to do this is to have your class extend Proxy. You need to override nextNameIndex(index:int):int and nextValue(index:int):*. If that is a bit confusing, just put breakpoints in your overrides when you try to do something like myObject[205].

Good luck :)

0

精彩评论

暂无评论...
验证码 换一张
取 消