I need to remove the value associated with a property in a Flex 3 associative array; is this possible?
For example, suppose I created this array like so:
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 error message at runtime:
Error #1119: Delete operator is not supported with operand of type XMLList.
How do I perform this operation?
Method 1: Using unset() function: The unset() function is used to unset a key and its value in an associative array. print_r( $arr ); ?> Method 2: Using array_diff_key() function: This function is used to get the difference between one or more arrays.
We can remove objects from JavaScript associative array using delete keyword. Approach: Declare an associative array containing key-value pair objects. Then use delete keyword to delete the array objects from an associative array.
Using unset() Function: The unset() function is used to remove element from the array. The unset function is used to destroy any other variable and same way use to delete any element of an array. This unset command takes the array key as input and removed that element from the array.
delete doesn't do as much in AS3 as it did in AS2:
http://www.gskinner.com/blog/archives/2006/06/understanding_t.html
However, I think your problem might be solved by simply using toString(), i.e.
var myArray:Object = new Object();
myArray[[email protected]()] = "foo";
delete myArray[[email protected]()];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With