2008/08/18/00.37.56
Avoid swapChildren and swapChildrenAt
Simply googling for the phrase flex RangeError swapChildrenAt returns enough reason to follow this advice. Here’s some pseudo-code that does work for swapping the depth of two children, A and B:
- A needs to be at a depth above B
- If not, then switch references to A and B.
- Remember the depths of A and B
- Remove A
- Remove B
- Add A to the level where B was
- Add B to the level where A was
As a side note: If you’re removing these children from inside either A or B, you’ll want to keep a reference to the parent in a local variable since you’ll lose it as soon as you remove A and B.
Original post by richard.lyman and software by Elliott Back