4 Replies Latest reply on Aug 18, 2010 1:14 AM by bill_baroud

    how to Set the currentState property of a viewStack child

    bill_baroud

      Hello,

       

      I am new to Flex (I use Flex 4) and have some problems to set the currentState property of a Spark NavigatorContent component included inside a ViewStack component.

       

      <mx:ViewStack id="myViewStack">
           <s:NavigatorContent id="myNavContent1">
           <s:Label text="aaaaa" />
           </s:NavigatorContent>
           <s:NavigatorContent id="myNavContent2">
           <s:Label text="bbbbb" />
           </s:NavigatorContent>
      </mx:ViewStack>
      
      <s:Button label="button1" click="button_clickHandler(event)" />
      

       

      For example, when clicking the button i would like to display the CurrentState property of the ViewStack selectedChild :

       

      protected function button_clickHandler(event:MouseEvent):void
      {                    
           var selectedNavigatorContent:NavigatorContent = myViewStack.selectedChild.name as NavigatorContent;
           Alert.show(selectedNavigatorContent.CurrentState);
      }
      

       

      error message : Object reference NULL.

       

      any idea of what's wrong with that ?

       

      thanks