2 Replies Latest reply on Jul 9, 2009 9:42 PM by zubinshi

    panel expand problem in viewstack

    zubinshi Level 1

      If there are 2 panels in a view stack. one of the panel will dynamically adding and removing components.  The problem I am facing now is the while adding and removing component in panel, the panel doesn't expand automatic(if it is not inside the view stack, it works fine). Please help me out. thanks.

       

      Following are the sample codes you can run:

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

      <?xml version = "1.0" encoding = "utf-8"?>

      <mx:Application

       

       

      xmlns:mx = "http://www.adobe.com/2006/mxml

      "

      layout = "

       

      vertical

      "

      verticalAlign = "

       

      middle

      "

      horizontalAlign = "

       

      center

      "

      backgroundGradientColors = "

       

      [0x000000,0x323232]

      "

      viewSourceURL = "

       

      srcview/index.html"

      >

       

       

       

      <mx:Script>

      <![CDATA[

       

       

      private function changePanel():

      void

      {

       

       

      if

      (viewStack.selectedChild == loginPanel)

      {

      viewStack.selectedChild = anotherOne

      }

       

       

      else

      {

      viewStack.selectedChild = loginPanel;

      }

      }

      ]]>

       

       

      </mx:Script>

       

       

      <!-- The Application class states property defines the view states.-->

       

       

      <mx:states>

       

       

      <mx:State name = "Register"

      >

       

       

      <!-- Add a TextInput control to the form. -->

       

       

      <mx:AddChild relativeTo = "{loginForm}

      "

      position = "

       

      lastChild"

      >

       

       

      <mx:FormItem id = "confirm

      "

      label = "

       

      Confirm:"

      >

       

       

      <mx:TextInput/>

       

       

      </mx:FormItem>

       

       

      </mx:AddChild>

       

       

       

      <!-- Set properties on the Panel container and Button control.-->

       

        

       

       

      <!-- Remove the existing LinkButton control.-->

       

       

      <mx:RemoveChild target = "{registerLink}"

      />

       

       

       

      <!-- Add a new LinkButton control to change view state

      back to the login form.-->

       

       

      <mx:AddChild relativeTo = "{spacer1}

      "

      position = "

       

      before"

      >

       

       

      <mx:LinkButton label = "Return to Login

      "

      click = "currentState=

       

      ''"

      />

       

       

      </mx:AddChild>

       

       

      </mx:State>

       

       

      </mx:states>

       

       

      <mx:VBox width = "100%

      "

      height = "

       

      100%"

      >

       

       

       

      <mx:ViewStack id = "viewStack

      "

      width = "

       

      100%

      "

      creationPolicy = "

       

      all"

      >

       

       

      <mx:Panel id = "anotherOne

      "

      width = "

       

      100%

      "

      title = "

       

      test"

      >

       

       

      <mx:VBox>

       

        

       

       

      <mx:Button label = "test

      "

      width = "

       

      100%"

      />

       

       

      <mx:Button label = "test

      "

      width = "

       

      100%"

      />

       

       

      </mx:VBox>

       

       

      </mx:Panel>

       

       

      <mx:Panel id = "loginPanel

      "

      width = "

       

      100%

      "

      title = "

       

      Login"

      >

       

       

       

      <mx:VBox id = "loginForm

      "

      width = "

       

      100%"

      >

       

       

       

      <mx:HBox>

       

       

      <mx:Button label = "a"

      />

       

       

      <mx:Button label = "b"

      />

       

       

      </mx:HBox>

       

       

      <mx:Button label = "c"

      />

       

       

      </mx:VBox>

       

       

      <mx:ControlBar width = "100%"

      >

       

       

      <!-- Use the LinkButton to change to the Register view state.-->

       

       

      <mx:LinkButton id = "registerLink

      "

      label = "

       

      Need to Register?

      "

      click = "currentState=

       

      'Register'"

      />

       

       

      <mx:Spacer width = "100%

      "

      id = "

       

      spacer1"

      />

       

       

      <mx:Button label = "Login

      "

      id = "

       

      loginButton"

      />

       

       

      </mx:ControlBar>

       

       

       

      </mx:Panel>

       

       

      </mx:ViewStack>

       

       

      <mx:Button id = "changeButton

      "

      label = "

       

      change

      "

      click = "changePanel()"

       

      />

       

       

      </mx:VBox>

      </mx:Application>