1 Reply Latest reply on Nov 5, 2006 6:16 AM by peterent

    Why can't you set selectedChild in MXML?

    Graeme Harker Level 1
      The Flex documentation insists that "you can't set a ViewStack's selectedChild property in MXML" without really explaining why. The following (intuitively correct) code, for example, compiles without error but crashes at run-time in Flex 2:-

      <mx:ViewStack selectedChild="{this.zero}">
      <mx:Canvas id="zero" >
      <mx:TextArea text="Canvas Zero" />
      </mx:Canvas>
      <mx:Canvas id="one" >
      <mx:TextArea text="Canvas One" />
      </mx:Canvas>
      </mx:ViewStack>

      I ran into this problem using a ViewStack as an itemRenderer inside a DataGrid cell.

      The documentation says "you cannot set the selectedChild property to a child that is not created" but also says "the ViewStack's children are not created until they are selected" (p541 of Developers). Am I not selecting it by asigning to the selectedChild property?