Jump to content
GreenSock

dezza

SelectItems bug [SOLVED]

Moderator Tag

Recommended Posts

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

Link to comment
Share on other sites

Yes, great catch. Thanks for pointing that out. It is fixed in the latest version (just posted this morning). Log into your GreenSock account to get it at https://www.greensock.com/account/

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×