Is it possible to clear a Flex flash.utils.Dictionary
? I have a Dictionary
that I want to clear (remove all elements).
views:
543answers:
2
A:
I don't believe there is an explicit clear command.
However, you could write your own that would loop through all the keys and run this
delete dict[key];
Or you can just reassign
dict = new Dictionary()
Jason W
2010-03-10 17:49:36
A:
I think this will work, but I'm not 100% sure, as you're modifying the dictionary while iterating over it:
function clear(d:Dictionary):void {
for(var id:String in d) {
delete d[id];
}
}
However, I generally just create a new Dictionary whenever I need to clear one (though if it's referenced in multiple places then that might not work for you).
Herms
2010-03-10 18:10:13