PDA

View Full Version : Can't delete child on change state!


handycam
08-02-2007, 04:11 PM
OK, I've go an app with two states. The base state has a panel, app control bar, and a viewstack. The second state should delte all of those and add a title window.

I created the second state,use AddChild to add the title window and removeChild to remove the IDs of the above items. I set a button to click="this.currentState='second'". I get this error:

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at mx.core::Container/removeChild()
at mx.states::RemoveChild/apply()
at mx.core::UIComponent/private::applyState()
at mx.core::UIComponent/private::commitCurrentState()
at mx.core::UIComponent/setCurrentState()
at mx.core::UIComponent/set currentState()
at cyor1/___cyor1_Button1_click()
at [mouseEvent]


OK, I wrapped the whole first screen in a canvas, and then use only one removeChild to remove the canvas. This works, but then my App Control Bar is not docked. So I try moving the app control bar out of the canvas and adding its ID as a remove child. The error happens again!!

I have even tried adding removeChilds for the app control bar and its child linkbar, same thing.

What's going on here?

dr_zeus
08-03-2007, 07:02 PM
I can't be sure without looking more deeply at your code, but my instinct says that is caused by one of the containers' creation policies. Perhaps some component hasn't been instantiated yet when you change your state.