Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I delete a value from an Object-based associative array in Flex 3?

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?

like image 853
Chris R Avatar asked Jul 20 '09 19:07

Chris R


People also ask

How do you remove a value from an associative array?

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.

How to remove value of associative array in JavaScript?

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.

How to remove one key and value from 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.


1 Answers

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]()];
like image 73
quoo Avatar answered Sep 28 '22 09:09

quoo