# Dictionary vs Object

**URL:** <https://forum.kirupa.com/t/dictionary-vs-object/300006>\
**Category:** flash\
**Created:** [November 14, 2009, 3:39am UTC](https://forum.kirupa.com/t/dictionary-vs-object/300006 "2009-11-14T03:39:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![substance](https://avatars.discourse-cdn.com/v4/letter/s/c6cbf5/32.png) [@substance](https://forum.kirupa.com/u/substance)\
**Post date:** [November 14, 2009, 3:39am UTC](https://forum.kirupa.com/t/dictionary-vs-object/300006/1 "2009-11-14T03:39:07Z")

</div>

So im creating a library that holds a bunch of myObjects. I ‘register’ these objects and give them a **label** (String) so I can access them later. There’s 2 ways I can do this easily:

[AS]var library:Dictionary = new Dictionary();  
//set reference (takes MyObject)  
library[myObject.label] = myObject;  
//get refernce (takes string, returns myObject)  
return library[“label”][/AS]  
[AS]var library:Object = {};  
//set reference (takes MyObject)  
library[myObject.label] = myObject;  
//get refernce (takes string, return myObject)  
return library[“label”];[/AS]

Though, I honestly think the best way to handle these objects would be using a Vector, that way I keep the object’s type. This would require more work though, having to store an id.

[AS]var library:Vector.\<MyObject\> = new MyObject();  
//set reference (takes MyObject)  
var id:int = getID()  
myObject.id = id;  
library[id] = myObject;  
//get reference (takes string, returns myObject)  
for(var i:int = 0 ; i \< library.length;++i){  
if(library\*.label == “label”)  
return library\*;  
}[/AS]

What do you guys think?
