Maybe you ran that code twice?

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of blc187
Sent: Monday, August 04, 2008 12:11 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] error: DisplayObject must be a child of the caller



I have a chart on stage that is attached to a VBox with a few other 
components underneath.

I want to remove the VBox but keep the chart. So I'm doing:

var myChart:LineChart = vbox.removeChild(lineChart) as LineChart;
this.addChild(myChart);
this.removeChild(vbox);

<mx:VBox id="vbox">
<mx:LineChart id="lineChart" />
<mx:HBox>
..... other components .....
</mx:HBox>
</mx:VBox>

However, I get the following error:
ArgumentError: Error #2025: The supplied DisplayObject must be a 
child of the caller.
at flash.display::DisplayObjectContainer/removeChild()

I know that removeChild() it is complaining about is vbox.removeChild
(lineChart), because I commented out this.removeChild(vbox) and still 
get the error.

I also know that the removeChild call works fine because I see the 
LineChart in the var myChart when I put a breakpoint on it.
Any thoughts on why it might be complaining?



 

Reply via email to