How to remove a value from an Object-based associative array in Flex 3?

I need to remove the value associated with the property in the Flex 3 associative array; is it possible?

For example, suppose I created this array as follows:

var myArray:Object = new Object(); myArray[ someXML.@attribute ] = "foo"; 

Later I need to do something like this:

 delete myArray[ someXML.@attribute ]; 

However, I get this runtime error message:

 Error #1119: Delete operator is not supported with operand of type XMLList. 

How to perform this operation?

+4
source share
2 answers

delete does not do as much in AS3 as it does in AS2:

http://www.gskinner.com/blog/archives/2006/06/understanding_t.html

However, I think your problem can be solved by simply using toString (), i.e.

 var myArray:Object = new Object(); myArray[ someXML.@attribute.toString ()] = "foo"; delete myArray[ someXML.@attribute.toString ()]; 
+10
source

Instead of deleting it, try setting it to null.

 myArray[ someXML.@attribute ] = null; 

Thus, it will be the same as any other value in an array that is not defined.

-1
source

All Articles