Flex Bug: swapChildren() doesn’t work on UIComponents

today i found another weird bug. i wanted to change the order of 2 elemente of a mx.containers.Canvas with swapChildren() but i got the following error:

[Fault] exception, information=ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
bzw.
[Fault] exception, information=ArgumentError: Error #2025: Das angegebene DisplayObject muss ein untergeordnetes Element des Aufrufers sein.

the error is totally nonsense because both elements are childs of the canvas. here is a little bit code to show the problem:

trace( this.getChildIndex( _currentDisplay ) ); // output: 0
trace( this.getChildIndex( _lastDisplay ) ); // output: 1
 
//-- doesn't work. throws exeption
//this.swapChildren( _currentDisplay, _lastDisplay );
 
//-- solution: 
this.removeChild( _currentDisplay );
this.addChild( _currentDisplay );

i got only 2 displayobjects in my canvas. if you got more than 2 you have to rewrite swapChildren by yourself. remove all childs and add it in the new order.

p.s.: everytime i use flex i’m feeling uncomfortable again because of some shit that doesn’t work like expected. i like flex but it seems to me that pure AS3 feels much more stable and reliable. if a have the choice i always prefer AS3.

Schlagwörter:

Comments are closed.