views:

891

answers:

2

I'm writing a flex program in an OO manner and I've got to the point of creating a ViewStack to hold various panels. My problem is that when I add a panel to the ViewStack it throws the aforementioned error. No doubt the answer is pretty obvious so here's the constructor for the manager class that holds my ViewStack.

stack = new ViewStack();
loginPanel = new LoginPanel;
regPanel = new RegisterPanel;
stack.creationPolicy = "all";
stack.addChild(loginPanel);
stack.currentState = "loginPanel";
+3  A: 

I'm not sure why you are setting the currentState property of the ViewStack. Are you trying to select that child? If so, try using the selectedChild property instead. This should work:

{
    stack = new ViewStack();

    loginPanel = new LoginPanel();

    regPanel = new RegisterPanel();

    stack.creationPolicy = "all";

    stack.addChild(loginPanel);

    stack.selectedChild = loginPanel;
}
Eric Belair
Right, "currentState" is used to select between view states you have defined for a custom component.
cliff.meyers
A: 

Why its not possible to easyly access Elements that are inside any ViewStack ? AHHRRRGGGHH !!

Tom
Property are not accesable if parent tab is not loadet one time. <br>Try this at init yout application: <br>for(var i:int = 0; i < Your_Stack.numChildren; i++) <br> Your_Stack.selectedIndex=i
Tom