# Looping through Dictionary objects

**URL:** <https://forum.kirupa.com/t/looping-through-dictionary-objects/300307>\
**Category:** flash\
**Created:** [November 18, 2009, 11:43pm UTC](https://forum.kirupa.com/t/looping-through-dictionary-objects/300307 "2009-11-18T23:43:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![IQAndreas](https://avatars.discourse-cdn.com/v4/letter/i/f08c70/32.png) [@IQAndreas](https://forum.kirupa.com/u/IQAndreas)\
**Post date:** [November 18, 2009, 11:43pm UTC](https://forum.kirupa.com/t/looping-through-dictionary-objects/300307/1 "2009-11-18T23:43:33Z")

</div>

I’m trying to do something along the following:

```auto
//Loop through all items in the dictionary to update each and every one
for (var key:DisplayObjectContainer in containerDict) 
{ 
   containerDict[key].updateText(); 
}

```

And Flash tells me “key” is supposed to be a String. Well, I could easily do that, no problems, even though I know all items in the containerDict are DisplayObjectContainers, so it’s probably treating the key as a String instead of an object. That’s understandable.

**The problem comes in when I want to do this:**

```auto
//Loop through all items in the dictionary and remove each one of them
for (var container:DisplayObjectContainer in containerDict) 
   { DebugText.remove(container); } 

```

Actually, it doesn’t remove the container, it deletes the DebugText instance associated with that container.

Here, there is no way I can treat the key as a string.

**Any workarounds?**
