3 Replies Latest reply on Sep 29, 2006 1:27 PM by ntsiii

    RemoveChild error with Viewstack

    mysticallord
      Every time I create a ViewStack, add two panels to the stack, and then add a state which removes a child from the second panel, I get a null reference error.

      Code:


      <?xml version="1.0"?>
      <mx:Application currentState="Test" xmlns:mx=" http://www.adobe.com/2006/mxml">
      <mx:states>
      <mx:State name="Test">
      <mx:RemoveChild target="{lbl2}"/>
      </mx:State>
      </mx:states>
      <mx:ViewStack id="vstack" width="500" height="400">
      <mx:Panel label="1" width="100%" height="100%">
      <mx:Label id="lbl1" text="Label"/>
      <mx:Button id="btn" label="Next" click="vstack.selectedIndex = 1;"/>
      </mx:Panel>
      <mx:Panel label="2" width="100%" height="100%">
      <mx:Label text="Label" id="lbl2"/>
      </mx:Panel>
      </mx:ViewStack>
      </mx:Application>



      This does not occur when only one panel is used, or when removing a child from the first panel. Why is this, and how do I get around it?

      Thanks,
      Aaron