2009-07-20 44 views
4

我需要刪除與Flex 3關聯數組中的屬性相關聯的值;這可能嗎?如何在Flex 3中從基於對象的關聯數組中刪除值?

例如,假設我創造了這個數組,像這樣:

var myArray:Object = new Object(); 
myArray[[email protected]] = "foo"; 

後來,我需要做的是這樣的:

delete myArray[[email protected]]; 

不過,我在運行時收到此錯誤信息:

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

如何執行此操作?

回答

-1

而不是刪除它,嘗試將值設置爲空。

myArray[[email protected]] = null; 

這樣它最終會與數組中未定義的任何其他值相同。

+3

這並不完全「相同」 - 它會將值設置爲null。如果您想完全刪除,刪除效果會更好;這樣,如果你爲對象上的每個對象執行類似的操作,則不會遇到空的「已刪除」值。 – Manius 2011-11-13 18:28:47

相關問題