A quick array question in AS3

Subscribe to A quick array question in AS3 5 posts

avatar for a3lex33 a3lex33 127 posts
Flag Post

Is it possible to use char or string indexes in arrays in as3? In the way that instead of:

array[0] = a;
array[1] = b;

I could use:

array['a'] = a;
array["str"] = b;
 
avatar for vesperbot vesperbot 1849 posts
Flag Post

use Object type or Dictionary type for this.

 
avatar for BobTheCoolGuy BobTheCoolGuy 3757 posts
Flag Post
Originally posted by vesperbot:

use Object type or Dictionary type for this.

But also, it is perfectly possible with Arrays in AS3 as well, yes.

 
avatar for BobJanova BobJanova 859 posts
Flag Post

You can attach dynamic properties to any object like that. But if that’s what you’re trying to do, either use Object (i.e. var x:Object = {}), or if the properties are always going to be the same, write a class to encapsulate them.

 
avatar for a3lex33 a3lex33 127 posts
Flag Post

Thank you for replies. I thought there had to be more efficient way rather than searching through all array/sorting the array.