Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
Adobe Flex SDK 3.6 (Release), Adobe Flex SDK 4.1 (Release), Apache Flex 4.11.0
-
Reproduced with the SDKs above in FP 11.9 on Windows IE; Likely an issue in all OS/SDK/FP combinations.
Description
Sample code:
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > <mx:Script> <![CDATA[ import mx.collections.XMLListCollection; import mx.controls.Alert; protected var mainXML:XML = <root> <item id="1"/> <item id="2"/> <item id="3"/> </root>; protected function addButton_clickHandler(event:MouseEvent):void { trace("Length before adding: " + mainXML.item.length()); // traces '3' var some:XMLListCollection = new XMLListCollection(); for each (var o:Object in mainXML.item) { some.addItem(o); } trace("Length After adding: " + mainXML.item.length()); // traces '5' BUT SHOULD BE STILL 3 } ]]> </mx:Script> <mx:Button label="Add Items" click="addButton_clickHandler(event)" /> </mx:Application>
Result:
mainXML.item XMLList is gets modified - the 2nd and 3rd items are added to it. That shouldn't happen and can cause very severe issues.
Workaround:
Do not use XMLListCollection. Array or ArrayCollection seem to be unaffected by this bug.
Related Issues:
This issue might share the same underlying cause: FLEX-21831