I think I have possibly found a bug in the TransformManager class to do with selecting items.
Please note I think this bug would be unlikely to occur if you were selecting/deselecting items using the mouse. I am probably only seeing it because I am supporting undo/redo operations in my application, so I am changing the selection programatically based on the history of user interactions.
The bug:
When setting the selection to be two items, and then setting the selection to be one (different) item, only one of the initially selected items is deselected.
E.g.
transformManager.selectItems( [ redItem, greenItem ] );
// returns transformItems for redItem, greenItem
trace( transformManager.selectedItems );
transformManager.selectItems( [ blueItem ] );
// returns transformItems for redItem, blueItem. This is wrong! it should just be blueItem.
trace( transformManager.selectedItems );
I believe the problem is a loop (line 1126) in the selectItems() method.
It is iterating over the _selectedItems array, but I suspect the length of the array can be modified during an iteration, prematurely exiting the loop before all items are iterated over.
I have seemingly fixed this behaviour by iterating over a copy of the _selectedItems array instead:
e.g.
var selectedItems : Array = _selectedItems.slice();
// ... iterate over copy instead
Can anyone confirm that this is happening or am I misunderstanding something here?
Cheers d