PDA

View Full Version : Resetting Dictionary containing XMLLists


chrisg1979
08-07-2009, 08:54 PM
Hello all,

I'm having trouble when trying to remove XMLList objects from a Dictionary.

The Dictionary needs to be reset to an empty state as each time a certain function is called it checks for the existence of keys.

I've tried the following (the Dictionary is assetsByPage)


for each(var obj:Object in assetsByPage)
{
delete assetsByPage[obj];
}


But I get the error:
TypeError: Error #1119: Delete operator is not supported with operand of type XMLList.

I think I need to delete the key itself, rather than the Object stored by the key, but don't know the syntax for this. Can anyone shed some light on it?

Thanks in advance

lordofduct
08-07-2009, 08:59 PM
if you want to for loop each key:


//note the lack of 'each'... just the 'for' will loop through the props or keys of an object
for (var key:Object in assetsByPage)
{
delete assetsByPage[key];
}


or you could just create a new Dictionary...


//old dictionary and all its keys are removed and replaced with brand new empty one
assetsByPage = new Dictionary();

chrisg1979
08-08-2009, 07:58 PM
Many thanks for this, the overwrite method is exactly what I need.